Setting a “no hiring men” policy is not allowed. Setting a “no hiring more than 50% men until women are 50% of total workers in the area being hired into” is approximately allowed, though there are nuances in how that can be defined that an employment lawyer would care to advise you on.
There are one or two relevant Supreme Court cases confirming the specific details and caveats around this, but
(I’m not your lawyer, and this is not legal advice.)