# first, find the correct id in this list of input devices
xinput list
# in my case, trackpad was id 11
# set the mapping for 11 (note reversed 4 and 5)
xinput set-button-map 11 1 2 3 5 4 6 7 8 9 10 11 12
# if you also reverse horizontal scroll (7 and 6)
xinput set-button-map 11 1 2 3 5 4 7 6 8 9 10 11 12