The idea of forming a new country on Earth has been discussed previously:
and setting up a new colony on the moon has been noted here:
The Outer Space Treaty says governments are not allowed to claim territory; https://en.wikipedia.org/wiki/Outer_Space_Treaty. There was an attempt to extend this, in the Moon Treaty, but it wasn't ratified by major spacefaring nations.
Private individuals with deep pockets are now backing space efforts. At some point, they may want to claim territory and set up a sovereign nation. However, as citizens of existing countries, that might be tricky. Also, given the current technological suite, it isn't like they can pack up everything they own, go to the Moon or asteroid, and set up a new country, without going back to Earth for supplies. An attempt by someone to lay claim to anything could be squashed by restricting their launch facilities (by force or legal means), and so the new country wouldn't stand a chance at "standing on their own two feet." This was noted in the answers above.
From a technological perspective, this might be circumvented if space launches were far cheaper and launch facilities were in a nation that didn't care (North Korea?) so long as you were paying cash, but then this just changes the point where you start your blockade/quarantine.
Is there a legal strategy (law of the sea analogies come to mind) where you could fight restrictions on launches from your own country?
The proposed Helios folks in the 'nationless organization' have an unspecified technology (antigravity?) that other nations don't have. If they were to pull a 'Declaration of Independence' and declare themselves a new nation, could they claim self-determination (https://en.wikipedia.org/wiki/Self-determination) which is also a UN principle? Would that override the Outer Space Treaty?
Frankly, if you've got an advanced technology that allows you to set up shop on the Moon and nobody else can get there, this appears to be a situation where "possession is 9/10ths of the law," and the politicians on Earth can complain all they want. It might even get more interesting when they start inviting select people to become citizens.
Legally, how would this be handled? Can these folks apply to be members of the UN?