What, theoretically, would have to happen for a US state to gain independence from the union and remain independent (i.e. not immediately get invaded by the US and reclaimed)?
The state legislature(s) and federal Congress would have to approve the change, in a process similar to how new states are added.
See especially Article IV, Section 3 of the US Constitution:
New States may be admitted by the Congress into this Union; but no new State shall be formed or erected within the Jurisdiction of any other State; nor any State be formed by the Junction of two or more States, or Parts of States, without the Consent of the Legislatures of the States concerned as well as of the Congress.
The Congress shall have Power to dispose of and make all needful Rules and Regulations respecting the Territory or other Property belonging to the United States; and nothing in this Constitution shall be so construed as to Prejudice any Claims of the United States, or of any particular State.