If it was about "respect", I doubt it would apply to women.
Even within my lifetime (and I'm not very old) women have traditionally worn hats indoors at formal functions. When I was a little girl, most of the older ladies in my church wore hats to mass. It was considered perfectly proper.
Nancy Reagan wore a hat at many important government functions and presidential addresses, including on election night.
I don't believe any first lady since the 80s has routinely worn hats indoors, but prior to Reagan, all First Ladies did; Jackie O had a matching pillbox hat for just about every suit she owned. Gloves, too.
It's never been considered polite, on the other hand, for men to wear hats indoors. Although they routinely wore them outdoors until the late 1950s/ early 60s. And some very old men still do.
These things may be passe now, but it certainly could not be considered a matter of "respect" that women be forced to doff their hats inside, even in a courtroom (which is surely no more holy than church, and requires no greater propriety than one's husband's inaugural address).
This is Georgia, it's the deep south. I'm sure they're aware of the custom of ladies wearing hats. In Georgia, they probably only stopped doing it, like, week before last. :roll:
It is not a matter of "respect".
I assume it is a safety precaution.