Freeze position without rigidbody

can i freeze the y position of a gameobject without using rigidbody?

thank you!

There is no need to freeze the y position of a GameObject without rigidbody, since it won’t be affected/moved by physics anyway.
You could apply a dirty fix by putting

transform.position.y = 0;

into the Update function, but much easier would be just not writing code which changes the y position of your object in the first place.