I believe it could be done partially in software. For example, I use Logitech TrackMan Marble with emulated wheel for scrolling—to achieve that I have something like this in
xorg.conf:
Option "ZAxisMapping" "4 5"
Option "XAxisMapping" "6 7"
Therefore, you could either use something like Cherry MX Lock for the modifier (
EmulateWheelButton), or add some dongle with a button, that would change HID, before the trackball.