Since I served in the U.S. military, it rankles me to hear female officers in Hollywood productions addressed (non-sarcastically) as "sir" (instead of "ma'am," or their proper rank or title).
Can “sir” be used to address female officers? confirms that in reality there is no precedent for a "gender-neutral" usage of the honorific "sir."
Some answers to What's the origin of referring to female superior officers as “sir”? suggest that this stage usage might have originated intentionally with Star Trek. For example, it would be consistent with a sci-fi work like Starship Troopers that features a striking emphasis on gender equality.
Although I can't enumerate them at the moment, I know that I have heard this quirk in many police and military productions spanning numerous genres and time periods. With parodies like The Orville I could believe it's intentional. But in serious police and military dramas: Is this just a product of some self-perpetuating ignorance of screenwriters and producers? Or is it done intentionally for some reason?