In the same way that Brexit happened, and the Scots had a referendum on staying in the UK, what would it take for California to leave the US?
There's no "legal" path for a State to become a separate country in the Constitution or any of the laws we currently have, and therefore, such a feat would be impractical at best. Texas v. White brought up that issue for Texas, the the Court found that a State may not unilaterally secede.
A State may only leave legally with the express permission of The United States of America. So, for any State, California or otherwise, to leave, would require either new laws that would require at least majority support from the remaining States, or a military operation to try and assert their independence, which would most likely be a bloodbath for the State attempting to do so. However it happened, it wouldn't be because of any Federal laws we currently have.
This is in contrast to Brexit, where all it required was a simple vote to leave. The European Union has provisions written into it that allow any member to leave if they desire. There was already a law in place to allow a secession to occur, and they decided to utilize that legal exit path regardless of the consequences.
Well, first you have to convince Californians that they want to secede.
Since there is no legal provision for this with California (some states may have negotiated deals that allow them to withdraw--although that's disputed), the only way to leave would be a constitutional amendment. Such an amendment could either create a general secession process or create one specifically for California.
To pass an amendment, you need either 2/3 or more of each chamber of Congress or a constitutional convention called by 2/3 or more of the states. Then ratification by 3/4 or more of the states.
You could try to just pass a federal law, but that would not align with most of the wording of the Texas v. White precedent. Same thing with unilateral secession, only more so.
Note that there are some issues to work out. For example, what share of the national debt does California have to pay back? How much Social Security and other trust fund money does it get? What about federal property in California? Does any military stuff go to California? How does citizenship work? Trade? When do Californians stop owing federal taxes? What to do in terms of currency? So on and so forth.