Get the mouse coordinates in normalized device space (i.e. -1 to 1 in both axes.) Then multiply this by the inverse of the (projection * camera) matrix (with a depth of 1/2 in directx or 0 in OpenGL). This gets you a point in world space, where the mouse is pointing to. Construct a vector from the camera position to this point, and make it unit length. This is the desired direction the player wants to point their ship in.
Now comes the tricky part. You have the forward vector (normalized, of course) of the ship as the current forward direction, and a desired forward direction, which presumably are not the same. What to do next depends on the motion model of your ships. Is it newtonian? If so then you have to be careful not to overshoot, as you likely have limited angular acceleration. The cross product of these two vectors will give you the vector you want to rotate about (the axis), and it is the sin() of the angle. If you don't have angular momentum, then you could just turn the ship by this axis and an angle which is limited by
RAD_PER_SEC * dt.
You can use Quaternion.AxisAngle to turn this into a quaternion which you can multiply onto the spaceship's orientation.
vec3 desired = (inverse(projection * camera) * (mx,my, 0.5)) - camera.position;
desired = norm(desired)
vec3 actual = norm(ship.getForwardVector())
vec3 axisangle = crossproduct(desired, actual) // may need to negate
// depending on conventions
float angle = arcsin(length(axisangle))
float dangle = min(angle, RAD_PER_SEC * dt)
quat rotation = Quaterion.AxisAngle(dangle, norm(axisangle))
ship.orientation = ship.orientation * rotation.
Make sure that arcsin and AxisAngle both use degrees, or both use radians.