rotating object 180 degrees

I’m trying to create such rotation, but I don’t know how to do it, I’ve used transform.Rotate(0, 0, 180, Space.Self); but it gives me a weird result, the object change position instead of rotating… Trying to achieve a hinge joint like movement, 180 at a time (OnTap in my case)

This is how I normally do it (in C#):

transform.localRotation *= Quaternion.Euler(0, 0, 180);

Or use the static method ‘Inverse’

transform.rotation = Quaternion.Inverse(transform.rotation);