If the power needed for the 40V bus is small (say, maybe a watt or two), then it makes sense to supply from 12V and boost to 40V on board. On the other hand, if significant part of the total power goes into the 40V thing, then just supply more than 40V and regulate it down to 40V with a DC/DC buck regulator. Then you can further buck down 12V, 5V, whatever you need. Note that 42V might not be enough, linear regulators have minimum dropout requirements and DC/DC bucks have maximum duty cycle or minimum off time, often around 90% or some hundred ns.
If you want to control the voltage using the MCU, this is a bit more involved. Fine-tuning is easy: typical solution is to connect MCU DAC output (or an RC filtered PWM output), through a series resistor, to the FB pin of the regulator, so that the normal FB resistor divider is still functional, but the DAC injects a tiny current offsetting the FB pin.
40V, 0.6A peak is really quite some power to boost from 12V. If you can freely choose the input voltage, I might not do it, it's realistically at least 3A from the 12V input. Of course you decide, if you need to run this off a car battery, then what else can you do but to boost. Forcing the end-user to buy an inverter to run a 48V mains supply would be a nightmare.
And by peak, I assume it's longer than some tens of microseconds, meaning capacitors won't help supplying it, and you need to design the power supplies to deliver the full peak current "continuously". The only compromise you can make by this being "just a peak", is in heatsinking.