M6 is one of the built-in Mcodes that can be 'remapped', Depending on the complexity of the customiziation it can be as easy as an ngc file or as complex as a python script:
linuxcnc.org/docs/2.9/html/remap/remap.h...lated_codes_t_m6_m61
[edit]
If you only require minimal changes to then start with section 5.6 in the document above.