The simplest "AI" (linear regression) will already factor this out if it has the data about the car driven and gender. Any remaining gender imbalance is attributable either to another factor or it is actually gender related (e.g. increased road rage, high speed driving and risky following behavior due to testosterone might be a stronger accident predictor than too careful driving (not speed matching fast enough when merging on the highway), too slow driving or worse spatial reasoning which are usually correlated with higher estrogen levels.)
In general the AI will just become a better predictor the more data it has available and the more detailed the data is. But an effeminate man or a manly woman might behave more than the opposite gender and thus be treated wrongly. We could probably solve this by tacking on a recent endocrinological report to every application, but this gets quite privacy invasive at some point.
In general if you get insurance you want to be part of a larger risk group to mitigate your effects. Having no insurance just means you have the most fair risk group, which is just yourself.