In Star Trek II: The Wrath of Khan, a female officer, Lt. Saavik, is frequently addressed as "Mister Saavik". It is claimed that this follows some real-life military (in particular, US Navy) tradition (Source 1, Source 2, Source 3):
In the US Navy the rank of an officer determines how they may be addressed in certain situations - Ensigns, Lieutenants (and JG Lts) may be addressed as "Mister -----", regardless of gender. Recognition of the rank earned, the role and not the gender.
On the other hand, various people who have actually served in the US Navy claim that this is not the case (Source 1, Source 2):
Well, I gotta tell ya shipmates I must disagree with some of the above due to personal experience, and I have served in many commands with many officers both male and female. In my entire U.S. Navy career of almost 20 years, I never heard a female officer refered to as "Mister." I heard many male officers refered to as such but never a female. And it wasn't just Lieutenants, it was any non-flag rank officer.