Names can be disqualified by the state registrars if they are prohibited.
"prohibited name" means a name that--
(a) is obscene or offensive, or
(b) could not practicably be established by repute or usage--
(i) because it is too long, or
(ii) because it consists of or includes symbols without phonetic significance, or
(iii) for ...
Since you didn't mention a country, I assume you mean the US.
The First Amendment prevents such a law. A name, given by a parent, is a form of expression, and in the US, the free speech clause of the First Amendment would render a law prohibiting such expression unconstitutional.
Since you didn’t mention the country, I assume you meant Germany.
Nobody forces potential parents to do anything. But when actual parents register their child’s name, it must be the right gender, and they don’t allow nonsense names either. “A boy named Sue” wouldn’t happen in Germany.
There are some names used for both genders (like Eike), the name “...