You can set this property with
xinput list to see the list of connected input devices. Note the exact name or the number of the device corresponding to your mouse (not the “Virtual core pointer”, but something like “Logitech USB-PS/2 Mouse M-BA47”). The name depends on your mouse model; I think the number is assigned dynamically, so you might need to do a bit of parsing to cope with multiple machines.
xinput set-prop "$device_name_or_number" "Evdev Middle Button Emulation" 1
xinput list-props "$device_name_or_number" to see a list of available properties, the exact set is different on different systems.
While you're at it, you might want to tune other settings (run
xinput list-props "$device_name_or_number" to see what settings exist). In particular, by default, I think the emulated middle button will be the same as the mouse wheel press, but that should be fixable by reassigning the wheel button (
Evdev Wheel Emulation Button).
See also Configuring Input Devices on the Ubuntu wiki.