The Treaty of Utrecht says that Gibraltar if it were to leave English-owned status would automatically be ceded Spain iirc. (Just found out) so that rules out the micronation idea.
Well yes but centuries old treaties can probably be changed. If it couldn't then Gibraltar would almost certainly refuse to leave the UK and the UK government could well get them a different deal with the EU than the rest of the UK. Trust me Gibraltan's fear of Spain's attempts to destroy their unique culture by submerging them back into Spain and their visceral dislike of the Spanish government is much stronger than their love of the EU.