I tested some AutoHotKey scripts I think this can work for you.
Download and install AutoHotKey
After installing it, right click on your desktop > New > AutoHotKey Script
a file will show, rename it as you like. Right click the file and select Edit Script, and paste the script below:
m::
KeyDown := !KeyDown
If KeyDown
SendInput {RButton down}
Else
SendInput {RButton up}
Return
Save and close the notepad window. Double click the script to make it start. You can see the AutpHotKey icon on the taskbar, you can use it to stop the script.
The script sets the M key to the RMB, when you press it, the RMB will be pressed and held, pressing M again will release the key.
Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.