Are you using Logitech's Control software? (If you are, I don't believe it allows you to customize it to run an AppleScript.)
If not, there is a program called
USB Overdrive that you could set up to run an AppleScript that would do just that. (Finding a script that would change to the next song or the previous song is one line and easy to find.)