If you use UIFLow you can make a loco controlled via a mobil phone easy however, the PWM lacks a H-Bridge and so will only work in one direction.

I have started a model railway series using M5Stack controllers here: https://www.hackster.io/AJB2K3/m5stack-model-railway-part-1-b109f7