To do this, go to /Library -> Application Support -> Logitech. Show the package contents (control-click on the file) of the file LCCDaemon, and go into Contents -> Resources. Show the package contents of the file seraph.plugin, and then go into Contents -> Resources -> Scripts. So the full path would kind of look like /Library -> Application Support -> Logitech -> LCCDaemon --> Contents -> Resources -> seraph.plugin --> Contents -> Resources -> Scripts, if you take --> as a sign to look at the contents of the package.
In that folder, you will find a list of files with strange file extensions (i.e. .stop or .next Track). These are just plain text files. You can replace the text in the files with an AppleScript. The Logitech drivers will use osacript to compile and run the scripts on the fly.
You can use newline characters in the file and it will still work. The changes take effect immediately (as soon as you save the file and press the button). I found (though I did no testing and it could be a placebo effect) that if you replace the text files with compiled scripts (with the same file names), they seem to run a little faster.
You can also set the mouse buttons to different actions depending on the application (like USB Overdrive X does). Usually you can just use USB Overdrive X to achieve this, but if you also own a Logitech keyboard, the drivers that you have installed for your keyboard will block the use of USB Overdrive X for your mouse. The quick workaround I found (as the Logitech support people could not help me) was to set the mouse buttons (all but the left click) to something really weird (i.e. shift-command-option-9) and use another program to map those key combinations (and therefore the mouse buttons) for each application you use.

