Yes, the state could be legitimate in denying its citizens the right to emigrate. Requiring citizens to stay in the country is one way of ensuring their political obligation to support the continued existence of the state is fulfilled. This obligation is grounded in a principle of reciprocity for which consent is unnecessary.What is the source for the political obligation here? Consent is a good candidate. Usually the basis for obligations, since the obligations are then taken to have been onboarded voluntarily. Wolff's Recognition Principle provides a substitute for actual consent, since we don't actually sign contracts with the state. But it's flawed because it requires individuals to have the state as is in line with their considered will. So it only covers those citizens who would not want fundamental changes to the way the state behaves.That said, a state which had to resort to legal means to retain its citizens is unlikely to be the kind of state for whom political obligation is generated. More realistically - the political obligation might only fall on that subset of citizens who actually benefit from the reciprocal arrangement of the state e.g. not disenfranchised minorities. These are of course the more applicable cases where we might question the limits of the state's sovereignty.