You should be able to adapt the "Dual X Carriage" feature for your project.
That allows a second print head (on the X axis) to move independently of the "main" X axis motor - and it can also be homed against its own endstop.
You can enable this feature in the `configuration_adv.h` file under "Dual X Carriage".
By default, all "Dual X/Y/Z axis" features use the first free extruder stepper driver - which would be E1 in your case.
You would have to adjust the `X2` parameters to allow you to zero the motor on the endstop (`X2_MIN_POS 0`, `X2_HOME_DIR -1`, `X2_HOME_POS X2_MIN_POS`), as well as setting the default mode to "`FULL CONTROL`" (`DEFAULT_DUAL_X_CARRIAGE_MODE DXC_FULL_CONTROL_MODE`).
As far as I understand, you can then use `T0` and `T1` to change between both "X axes", with `T0` selecting your real X axis, and `T1` your custom stepper motor.