“Secession is illegal”
The British said that it was “illegal” for the American colonies to secede from the empire.
They changed their mind quite readily after getting their a$$es kicked not once, but twice.
What is “legal” is what can be enforced with the strength of arms.
Government decides what is illegal, and they use force to make sure people obey. Government is the entity which has a monopoly on force. That's what government is. That's what law is.
For revolution, civil war, or secession, any discussion of "legality" is simply misplaced. Either you are strong enough to get your way or you are not. There's nothing more to be said.