When clicking the mouse button, instead of setting the new rotation to transform.rotation, store it in a custom variable, say targetRotation. Then in the same Update() method, but outside the Input.GetMoustButtonDown scope, you can rotate towards the target rotation like this:
And generally we call this “lerping” or “interpolating”, ie changing a value over time. There are typically two kinds of methods: Lerp (linear interpolation) and Slerp (spherical interpolation). You’ll find these in the Quaternion, Vector and Mathf classes for instance.