STM32 SWO & OpenOCD with Variable SysClock
The question didn't specify the type of STM32 in use.
I checked documentation for STM32L4x5/STM32L4x6 as an example:
Section 48.17.8 of the
Reference Manual
states that 


  TRACECLKIN input is internally connected to HCLK. This means that when in asynchronous trace mode, the application is restricted to use time frames where the CPU frequency is stable.


SWO (the Asynchronous Mode of TPIU) is a asynchronous one-wire protocol that transmits symbols, either as a Manchester code or NRZ. 
In either case, the receiver must know (the order of magnitude of) the baud rate in order to distinguish bit changes/repetitions from signal noise.

Therefore, I think that changing SWO baudrate on-the-fly can not be implemented in any useful way.

Edit:
I might have misunderstood the question. Is the goal to change the HCLK frequency during runtime "every now and then" or only once during power-up?
In the latter case, the trace adapter can be configured at the target frequency (through OpenOCD, too, I recon), and tracing will work from when HCLK has reached that stable frequency.