Hold torque during pause to change filament
Is ADVANCED_PAUSE_FEATURE enabled in your printers configuration_adv.h file?
There is a PAUSE_PARK_NO_STEPPER_TIMEOUT option included in there, which prevents the steppers from timing out during a pause, and may be more robust than a G-Code command if you plan to manually pause and resume the print instead of setting it up in the slicer.

Alternatively, in the same file,

#define DEFAULT_STEPPER_DEACTIVE_TIME 120
#define DISABLE_INACTIVE_X true
#define DISABLE_INACTIVE_Y true
#define DISABLE_INACTIVE_Z true  // set to false if the nozzle will fall down on your printed part when print has finished.
#define DISABLE_INACTIVE_E true


can be found. You may want to increase the DEFAULT_STEPPER_DEACTIVE_TIME, or set 

#define DISABLE_INACTIVE_X true
#define DISABLE_INACTIVE_Y true
#define DISABLE_INACTIVE_Z true  // set to false if the nozzle will fall down on your printed part when print has finished.


to false to keep X, Y and Z engaged while allowing movement of the extruder stepper only.