Cube flipping upside down when I rotate it

I’m using LookAt to rotate a cube, but when it goes upside down it rotates from 90 on the Y to 270 and flips the texture upside down. I put a rigid body on the object to restrict the Y rotation but that did nothing. Any help?

Its gimbal lock

How do I fix that? Or avoid it altogether?

How do I prevent the cube from flipping upside down while using Transform.LookAt()?