May be, may be not.
In the code it is checked "if (fullPics[i].gender == g) ..." So, if there's a portrait for specific gender for target character (unique or generic specie) then potion would work. If not - it would write "the item won't have any effect" in game log (bottom-right corner) and potion charge won't be spent.
There was specific gender-locked units in the game, but generally should be doable