Modifications on the trains are matter of taste. Generally speaking most people don't mind modification on the interior (motor, gearbox, electronics) in order to improve the driving performance. On the other hand, there are some that will absolutely not accept any modification that is visible on the outside if the real loco doesn't have that, ie. its ok to modify the look as long as the result is more accurate and true to the real one. Then there are collectors that value the model only if it hasn't been altered in any way, preferably never taken out of the box. Then there are those that value the box as much as the loco itself (only when buying, when selling it usually doesn't matter
).
Most electronics in these locos (called decoders) are so called multi-protocol, meaning they will work on two main modern protocols (DCC and MFX), but will also work on legacy digital and analog systems - no digital signal, just clean DC or AC in case of Marklin. Of course I'm talking about digital systems, there are still plenty of analog locos being produced, but this system in OP is digital.
Depending on manufacturer, there might not be enough room in locomotives to stuff in a whole lot of additional electronics. As you climb the price bracket of the model you lose space inside.
For a while I was trying to do something similar to what you're describing, but for another purpose. I wanted the loco to detect if it crashed into something, or perhaps a wagon derailed and snagged something. There were a few issues I encountered. Axle rotation sensor can easily be done, but some locos have all the wheels driven, so you can't tell when it crashed, since the wheels will continue to spin (the motors are quite strong). Next I tried sleeper detector, but even with brand new tracks, right out of the box, I was getting inconsistent results between different production runs. When I put the loco on the track, the problem was only made worse by dust and various inconsistencies. Next on the list was a vibration sensor, but again, loco vibrates during a stall just as it does during normal operation. I gave up before getting to IMUs.
What there is on the market offered as a product is RFID reader that can be placed next to the track, and each loco gets a tag, but that does not offer position readout, only that that specific train passed a certain point, so not really a competitor to the OP thing. We have a few locos that use WIFI for live video feed, but we are not really happy with them. The range is a bit short (our layout is big, but still...) and we had trouble keeping the connection up. Short circuits are not uncommon on the layout, and each time the connection drops so we got tired of manually reconnecting the WIFI several times per day.