I was in a courtroom for a traffic ticket and witnessed a Judge and a Muslim interact.
The Bailiff instructed everyone to stand and remove hats, this guy did not.
He did not mind standing , but he kept his hat on.
So the judge addressed him directly.
... after a few questions were answered ...
The judge was assured that no disrespect to the court was intended and that the reason for the hat was religious obligation.
So he allowed it.
There is room for discretion and accommodation, but there must be good reason for it , if it causes a larger problem.
I remember news accounts of several Muslim women who wanted to keep scarves on their hair or their faces partially hidden when their pictures were taken for drivers license, this seems to be where the line is , they were disallowed because having a masked picture on the drivers license ruins it as an ID and so ruins it as a permit to drive the states roads. They were still free to walk or ride , just no driving with a masked ID.