What is the problem in setting the pulse length in HAL_TIM_PWM_PulseFinishedCallback? It will be valid for the next pulse, and I can’t see how it could be changed earlier; setting it in HAL_TIM_PeriodElapsedCallback may be too late for the current pulse (already started) and will thus have a longer latency.
By the way, what do you mean by “just in time”? As you can’t change the period of the PWM output, but only the cyclic/ration (period/pulse_length) you can not obtain an immediate effect, just an effect on the current (if a pulse is current) or on the next pulse (if between two pulses). Just setting CCRx when you decide what the next pulse length must be wil do its effect as soon as possible.