In the example image provided, the simplest solution would be to just detach the foot and have it rotate by itself instead of with the pants leg, then the geometry wouldn't collapse inward while rotating it.
You could use quaternion based controllers but animators usually whine about that. Or... conventionally people will split the control across two nodes, Eg. one handling x/y and the other z. It's a common problem at shoulder joints so a bit of googling should show up some examples of solutions.