how to rotate a GameObject between angles 90 and 270

I have a 2D GameObject that changes velocity at each game loop iteration. I want to also update its rotation, simply heading the velocity vector. I’m currently using

transform.rotation = Quaternion.Euler(0, 0, Mathf.Asin(rigidbody2D.velocity.y / rigidbody2D.velocity.magnitude) * Mathf.Rad2Deg);

However, this rotates the object only between 90-0, and 270-0. When the angle exceeds 90, it automatically changes to 270 and keeps on increasing from there.
I’ve tried almost all of the suggestions here but none of them solved my problem. Any help would be appreciated.

Assuming the right side of your object is considered the front, you can point the object in the direction it is moving using:

var vel = rigidbody2D.velocity;
var angle = Mathf.Atan2(vel.y, vel.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);