Yes, this is very common and sometimes called a PWM DAC.
The simpliest way is to put the i/o pin PWM signal through a lowpass filter (resistor and cap to ground)
eg

A good starting point might be using a 100Hz low pass filter and a pwm frequency at maybe 4khz.
The higher your low pass filter frequency is the faster your dc signal will respond to pwm changes.
However
The closer your low pass filter frequency gets to your PWM frequency to more ripple you will get on the DC output.