Your SW should ensure MODER field is written in a single access, so the and/or must be done using internal variable and not directly anding/oring inside the GPIO register.
This is how it is done in the HAL code.
At pure HW level, doing in that way, the two MODER bits will change in 'same time', there is still a potential skew in the range of sub-nanosecond, which cannot be seen on external pin (beware that even if probably is very low, it is not guaranteed that it will never be seen on internal input path on same IO, like EXTI, if used).
Another solution (which could be used in addition to the previous one), to ensure a '1' level even if you temporarily drive input mode (not work for analog mode), is to enable a pull-up on the TX pin (only during MODER changes if you are chasing micro-amps on your application). Obviously, the internal ~50kohms pull-up could only ensure a '1' if external circuitry load does not pull-down the output.