Multiplex usage of I/O pins: PWM pulse output + UART
Of course! When you read the datasheet and user guide of your STM32, you'll notice that all the output pins serve several functionalities, which are configured by setting some register to the appropriate value.

Your firmware does that somewhere to put the pins to the right output mode and "connect" the PWM (timer) module to them.

You just do the same, but with UART, after boot.

Note that basically all STM32 chips already come with a bootloader, which you can enable, that allows you to load firmware across a serial bus, before the regular firmware boots. So you probably don't even have to implement anything, just enable that bootloader by using the BOOT0 pin of your STM32. Read the manual! (RTFM)