Even though this information may be outdated, I wanted to share how I successfully implemented it since it remains the top search result on Google.
To prevent rolling (locking the z-axis), you can stop rotateCamera() from modifying the camera's Up vector.
To achieve this, simply comment out the following line (approximately line 200):
_this.object.up.applyQuaternion(quaternion);
If desired, you can also restrict the camera's rotation vector by adding either:
_this.object.rotation.z = 0;
or
_this.object.rotation.set(0, 0, 0);
to the end of the function. However, in my experience, this adjustment didn't have a significant impact since most of the rotation occurs due to the camera's movement in relation to its lookAt target (_this.target in the trackballControls.js file).