can PWM and Resistance be exchanged?

The answer will depend on if you wish to change the output voltage digitally and if you require low ripple. pwm + a filter will provide a variable voltage but it also provides ripple that gets passed onto the output un-attenuated.

This is where a digital pot / dac would be very helpful to achieve low ripple output.

That assumes no negative feedback on the part of the mcu.