Physics question (or: how to steer a starship)

This is a general physics question although I am using panda and bullet.

So lets pretend that you are playing a top-down tactical space ship game with Newtonian physics engine. You can click on the screen and your ship will turn to face that direction. Your ship has a mass and a maximum torque that the thrusters put out to rotate it.

I figured out a method to apply the torque to a ship that is not rotating, but I can not figure out how to do it for a body that already has an angular velocity. So I am poking you very smart people to point me (pun intended) in the right direction.

you poke into rigid body physics here or clasical mechanics.
it’s actally pretty simple given you have the moment of inertia.
it’s like a 1:1 equivalent to linear motion. but instead of forces, it’s torque, and instead of mass, it’s moment of inertia. and instead of linear speed it’s angular speed.

the rest goes according to your favorite physics textbook.
if you want to calculate the time/torque you need to stop it, you may simply calculate the other way round (speeding it up from still and invert the result. later formular is more commonly found in books)

As long as you are applying the torque around the z (upward) axis, it doesn’t matter if spaceship already has an angular velocity, it will just continue to accelerate.

If you are using displaced linear forces to to create a torque, that might be a problem because you have to rotate the direction of the forces and displacements along with your ship to keep it rotating. But if you apply torques directly, it shouldn’t be problem.