There is no problem. Random Acts of Senseless Violence by Jack Womack, Friday by Robert Heinlein and many of his short stories, Contact by Carl Sagan, Big U by Neal Stephenson, Cybernetic Samurai by Victor Milan. It's quite common in speculative fiction and fantasy anyway.
The observant writer shall have no problem. The unobservant one will pointlessly limit the possible scope of their narrative.
Just like female authors often write a story with a first person male protagonist.
The truthAuthors who socialize and are well informed about the world lose any wrong ideas fast. For instance, out of three engineers today I spoke with, two were female. If a male author presumes that his perspective character is very unlikely to be an engineer because she is female, ashe'll end up unnecessarily restricting himself in terms of what can occur in the story. It may end up worse than unrealistic: boring.
As Cordelia Fine writes in Delusions of Gender, well controlled experiments show that there are no gender based differences in thinking atthat are not conditioned, or which are not due to mistaken beliefs and stereotype fear.
And all that isThere are only slightly different preferences, not mental can be learned (and presumably has been) by whicheverabilities, in childhood, due to slight sex differences in the brain. These turn out not to be sex differences that affect abilities.
So nothing prevents an author iswhatever their gender from writing in the perspective of the other gender, if they are well informed about a wide variety of life histories.