To expand on SDPhantom's post, you can additionally mask the texture
Lua Code:
local genders = {nil, "male", "female"}
hooksecurefunc("UnitFramePortrait_Update",function(self)
if self.portrait and UnitIsPlayer(self.unit) then
local _, race = UnitRace(self.unit)
local sexID = UnitSex(self.unit)
local atlas = GetRaceAtlas(race:lower(), genders[sexID], true)
self.portrait:SetMask("Interface\\CharacterFrame\\TempPortraitAlphaMask")
self.portrait:SetAtlas(atlas)
end
end)