Maybe....
You can set buttons that set a HAL pin to run MDI commands, then the MDI command can be a user-defined M-code that can be any executable file. It's a bit convoluted, but it works.
linuxcnc.org/docs/stable/html/config/ini....html#_halui_section
and
linuxcnc.org/docs/stable/html/gcode/m-code.html#mcode:m100-m199
Alternatively the GladeVCP and probably QTVCP allow you to embed code directly in the button.
linuxcnc.org/docs/stable/html/gui/gladev...on_widgets_reference
And, any normal UI element can call handler code in the backend file to do the same thing, possibly with the Python os.system("ethercat upload -t int32 -p 0 0x2001 0 0")
Or, you could use a custom HAL component (I wuld probably use Python Userspace) that has HAL pins that connect to the buttons and sends the commands when the pin values change. This approach would (probably) work best for physical hardware buttons, though the MDI_COMMAND approach can also work that way.