Can you share your schematic?
It is for office work so I cannot share the schematic.
What device is providing the 5V supply, and what power supply is it derived from?
XTR117 is providing 5V and it is derived from 24V input
Are the two MCUs fully pin-compatible?
Yes they are.
It's possible that during programming a pin on the MCU is temporarily configured as an output and is being driven against either another output or a fixed reference, which could cause enough current flow to drop the supply voltage or even damage a component.
Only pins that are connected to the MCU are the programming pins SWDIO, SWCLK, RESET & 2 Chip Select and SPI bus and Boot0 is grounded.
Also if there is such a pin that is sinking current then why work with other pin compatible controller.
And parts themselves are not taking much current when you place one component at a time and measure current then MCU + 5V Reg + 3V Reg + DAC take < 1mA like ~500uA or so, but as soon as the ADC is added the voltage start drooping.