Yes
After the Civil War the Supreme Court ruled that the Acts of Succession of the southern states were unconstitutional. That is, they were and had always been part of the United States even if they said they weren’t.
So, a Constitutional amendment that allows successionsecession would need to be passed granting that right. This would be similar to Article 50 of the Treaty on European Union that allowed the UK to leave the EU.
There would need to be a way of determining the exact process because all states contain a lot of Federal installations with some western states being more than half Federally owned. This could be in the amendment but, more likely, it would simply empower Congress to determine the process.
Is this legal? Absolutely. Is there any real chance of this happening soon? Absolutely not.