You can do that with KeyMapper, and I have a lot of custom actions set up with it.
https://f-droid.org/packages/io.github.sds100.keymapper/
I have double-press volume down set to toggle mute, though, since I'm already using long press of vol up and down to do next/prev track for my music player.
Regardless, I cannot recommend KeyMapper enough. It's pretty fantastic.