I've tried it out, and it doesn't seem to be working in CAS. This is probably due to the custom gender functionality.
However, the gender restrictions do seem to work outside of CAS. Invalid gender-Locked traits chosen in CAS will be removed once the lot loads, and the traits do not show up in the in-game trait selection window that pops up from using a re-traiting potion or MC Command Center's manage personality traits option.
So while other traits can be restricted just fine, personality traits cannot since they're chosen in CAS, and sims with the restricted gender will end up with a blank trait slot when they load.