Is there a way to change the direction a motor goes with GCode instead of reconfiguring Marlin firmware?
You can use
M92 to change the axis steps per unit to a negative value, which causes it to move in the opposite direction. I.e. if normally your X axis has 160 steps per mm, using
M92 X-160 will invert all of its movements.
However, this is more of a hack than a real, intended solution. It would be better to (if you are concerned with the homing direction) change the configuration to have the printer home in the other direction. Unfortunately, this can only be done by changing the firmware and not though G-code.