From: Rabbi Moshe Sofer
To: Banovitz
The Chasam Sofer rules that a rabbi who obtained his position through a government appointment rather than communal consent acted improperly and is unfit to serve. Even if dina d'malchusa validates the appointment itself, it cannot compel the community to pay his salary, making every penny he takes from communal funds outright robbery. As a practical compromise, he may serve as Av Beis Din with judicial authority but may not bear the formal title of Rav until the community voluntarily accepts him.
Source: Shu"t Chasam Sofer CM §19