Using UART to program a device with another sensor connected to the same UART - how to disconnect TX when the device is programmed?
Using a spare IO line from the RaPi you could control an analogue switch that can be used to disconnect the sensor's TX line. It's a lot cleaner than using a transistor and you can get pretty small one from TI for instance. Don't forget to re-enable the sensor via the analogue switch when you have finished comms OR, if you want to make it more fail-safe in that respect use a monostable so that it automatically reconnects after a few seconds. To keep it disconnected for longer you would need to keep toggling the spare IO line (a bit like how a watchdog timer works).