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.
The source is incorrect, in that 'Mister' is not a rank that is earned, but is simply an alternative way of referring to officers of a particular rank by their subordinates, or addressing them by their superiors. That is, the term 'Mister' is a consequence of the biology of the person who holds that rank, rather than a rank in itself.
Take for example, in British-influenced militaries, a Lieutenant J Smith:
(1) Self-description: Gender neutral.
This person would answer the phone as "Hello, this is Lieutenant Smith".
(2) Addressed by subordinate: Gender specific.
(J=John): 'Sir, could you please answer the phone.'
(J=Jane): 'Ma'am, could you please answer the phone.'
(3) Addressed by superior: Gender specific.
(J=John) 'Mr Smith, could you please answer the phone.'
(J=Jane) 'Miss/Ms/Mrs Smith, could you please answer the phone.'
(4) Referred to to a third party: Gender specific.
(J=John) 'Mr Smith answered the phone.'
(J=Jane) 'Miss/Ms/Mrs Smith answered the phone.'
In British-style armies at least, the Mr/Ms/Miss/Mrs terminology is specific to Lieutenants and equivalent (i.e. only for the most junior officers) (see https://www.debretts.com/expertise/forms-of-address/professions/the-armed-forces/). For example, with captains, the gender neutral 'Captain Smith' would be used in (1), (3), and (4). Only in (2), when being directly addressed by a subordinate, would the gender-specific terms 'Sir' or 'Ma'am' be used.
The US Navy appears to have retained this "Mister" style of address which other branches of the US military discarded, and also used it for more senior ranks (up to commander), but certainly retained gender distinctions (see http://abbot.us/DD629/ranks/).