Preserving Velocity during rotations

Essentially, what I want is when the Rigidbody turns (performed by rigidbody.AddRelativeTorque) it will correct the velocity so that the velocity is relative to the transform.forward. So if I have a Global Velocity of Vector3(0.0f, 0.0f, 100.0f) with a transform.forward of Vector3(0.0f, 0.0f, 1.0f) which then changes to Vector3(1.0f, 0.0f, 0.0f) which would mean the Velocity would be updated to be Vector3(100.0f, 0.0f, 0.0f).

I've been using this to do it so far, simply using the global transform.forward * Velocity.magnitude:

rigidbody.velocity = new Vector3(transform.forward.x * rigidbody.velocity.magnitude,
                                 transform.forward.y * rigidbody.velocity.magnitude,
                                 transform.forward.z * rigidbody.velocity.magnitude);

This works well except if there is a negative velocity involved, for instance a Velocity of Vector3(0.0f, 0.0f, -100.0f) when transformed with this process will loose the signed value as the magnitude is absolute so instead of (using the same case as before forward = Vector3(1.0f, 0.0f, 0.0f)) the Velocity being Vector3(-100.f, 0.0f, 0.0f) it's Vector3(100.0f, 0.0f, 0.0f). There's probably a simple fix for this but I just can't see it today...

You probably want to have an if, then -

if ( Vector3.Angle( rigidbody.velocity, transform.forward ) > 90 ) { // if thing moving backwards
  // multiply by negative rb.vel.magnitude
} else {
  // use current code