Surely, a man can be a role model for a woman in science (and vice versa) - e.g., if you are from the same small ethnic minority as the role model. However, male/female lifestyle, upbringing, interests, challenges, etc. are quite different in general, even in otherwise very homogeneous (western) societies. Therefore, the role model having the same sex/gender is very important.
(Just my view - I don't have evidence or experience in this regard).