How do I achieve "inertial" camera movement for mouse look?

I stumbled upon a way to use .Lerp for camera look which makes it feel intertial. In short, it looks like this:

yaw += Input.GetAxis("Mouse X") * mouseSensitivity;
pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity;
pitch = Mathf.Clamp(pitch, -maxLookAngleY, maxLookAngleY);
    
camera.transform.localRotation = Quaternion.Lerp(camera.transform.localRotation, Quaternion.Euler(pitch, yaw, 0), Time.deltaTime * mouseSensitivity);

Now, I know you are not supposed to use Lerp like this, but it gives mouse look a great “inertial” heavy feeling to it (the movement isn’t instant and is delayed, when you stop moving mouse the movement continues for some time).

I would like to reproduce this in some other way (or fix the current way), because as of now it sometimes “jumps” to the direction that is the opposite from current rotation at seemingly random times.

Any ideas?

After some experiments I think I figured the cause of the problem but am not quite sure how to go around it. I think what is happening is that since “current” (actual) rotation angle is delayed compared to “target” rotation, when you move the mouse there are points at which target angle goes say from -179 to +179 and therefore the direction of “current” actual rotation changes.