I think this cant work, PhysX body flags and forces are for physics objects, not for character controllers.
A character controller is controlled not by physics but by your script. If you want an axis to be frozen for a character controller then just dont move or rotate it along this axis.