Hi @Yarash,
Welcome to the forum
I didn’t get the purpose, but a custom g-code is possible and relatively simple.
You can get further info in some threads about it, e.g., Custom g-code
or directly at the source:
Linear Move | Marlin Firmware
To be safe, test it near the printer to manually stop (power down) if necessary. If you prefer, paste it here so one can check it.