Is it possible to make a USB device that would alter mouse data on the fly?
What about a software solution?

On Windows, you can intercept the mouse actions with an application, which can be as simple as this AutoHotKey script: 

#NoEnv
SetBatchLines -1
Process Priority,,R

BlockInput Mouse        ; user mouse input is ignored during MouseMove
CoordMode Mouse, Screen ; absolute coordinates
SysGet m, Monitor       ; get the screen edges
mLeft += 1, mRight -= 2, mTop += 1, mBottom -= 2
SetMouseDelay -1        ; fastest action

MouseGetPos x0, y0      ; get initial mouse pointer location
SetTimer WatchMouse, 1  ; run the subroutine fast (10..16ms)
Return

WatchMouse:
   MouseGetPos x, y     ; get current mouse position
   x0 += 2*(x0-x), x0 := x0 &lt; mLeft ? mLeft : (x0 &gt; mRight  ? mRight  : x0)
   y0 += 2*(y0-y), y0 := y0 &lt; mTop  ? mTop  : (y0 &gt; mBottom ? mBottom : y0)
   MouseMove x0, y0, 0  ; set new position as old, for the next timer
Return

!z::ExitApp             ; stop the madness; make the script persistent


The same logic can be used to solve the problem in any application programming environment (C++, C#, etc.) which can access the Windows cursor functions. 

On Linux, it's as simple as modifying a property for your mouse with xinput, as ben wrote: 

xinput set-int-prop "USB Optical Mouse"  "Evdev Axis Inversion" 8 0 1


You'll need to substitute your device name (xinput -list | grep -i 'mouse') for "USB Optical Mouse".

Further questions on this software should be directed to Stack Overflow, our site for programming.