No. You will be feeding battery/decoder output back on to the track, which will either bleed power from the motor, cause a short, or feed something else sitting on the tracks.
The simplest solution is to incorporate a plug-and-socket in the wiring from the track pickups to the motor. Bachmann has such a plug between the boiler and the chassis on their 4-4-0/2-6-0, as the polarity switch is inside the boiler, feeding the motor, and thus you can remove the boiler without cutting wires. [Always a good thing - speakers should have plugs for the same reason.]
And with a socket on the motor feed, you can alternate between the track power and the battery power, just by switching the plugs.
I’m just setting up a tender so I’ll post a few photos of the rig.
In the meantime, here’s some ideas for plugs. Note that I buy the ones with wires attached:
Motor feed plug/socket pair:
https://www.aliexpress.us/item/2251832830442479.html
Battery feed plug (so you can remove the battery if it fails) compatible with Aristo feed plugs used between their locos. The 4-pin or 6-pin versions are also good for connecting engine and tender, as they latch together:
https://www.aliexpress.us/item/2251832623444425.html
These are useful for various purposes, including speaker connections:
https://www.aliexpress.us/item/2251801676056891.html
P.S. Aliexpress can take 6-8 weeks shipping unless you manage to snag 12-day shipping. These wires are also available on eBya and other sites.