Someone wrote a script to do this for Pico-8. It sets up hooks for the volume buttons and then launches Pico-8, all within the same script. It’s essentially a wrapper for Pico-8.
The same thing could be adapted to launch anything else, and assuming you didn’t need those buttons for the thing you were launching (like Retroarch), it should work.
Might be nice if someone tweaked this script a bit to be more generic and maybe take a single parameter for the target application to launch. Then it could be used in scripts and could take over the volume keys for anything.
It would be even nicer if this was done properly, as a system service (and maybe more efficiently). Just a guess, but I imagine most of us would want the volume buttons to work most of the time. If there was a way to override them (disable the service via a command when launching the target application), that would probably make more sense. Then if you wanted to use the volume buttons for something else, you could, but by default they would actually control the volume.
Anyhow, this might be useful if someone wants to tinker: