"1. A deputy sheriff may require individuals entering the courthouse to remove masks, veils, or other face coverings at the security checkpoint, without regard to whether the individual claims a religious basis for remaining masked or veiled, if the sheriff's office has a neutral and generally applicable policy of requiring removal of face coverings for security purposes.
"2. To minimize potential conflicts between the requirements of courthouse security and the religious practices of individuals entering the courthouse, it would be useful [but not legally mandated] if security details were comprised of both male and female officers and if a private space were available at the entrance of the courthouse for those individuals whose religion discourages removal of a head covering in public."
So opines the Maryland Attorney General. Maryland has no mandated religious exemption regime, so this is clearly right.
About half the states do have such a regime, either under the state constitution's religious freedom cause (as interpreted by state courts) or under a state Religious Freedom Restoration Act; and so does the federal government, as applied to federal action. The Maryland AG says, though, that even under such regimes no exemption from a policy of "temporary removal ... of a head covering," because the policy likely "would survive strict scrutiny [mandated under such exemption regimes] as a narrowly tailored effort to further a compelling interest in courthouse security."
The AG doesn't discuss whether considering sex in assigning guards to the checkpoint (or perhaps even in hiring guards, if not enough female guards are available), or in assigning guard duties at the checkpoint, would violate Title VII of the Civil Rights Act of 1964 or any similar Maryland law. As I discussed in this article, the "bona fide occupational qualification" exception to bans on sex discrimination in employment would generally justify some sex classifications aimed at protecting privacy. I know of no caselaw on whether this would cover accommodating privacy concerns that go beyond normal social privacy norms -- please let me know if you can point me to some such caselaw -- though I'm inclined to conjecture that it probably would.