The RC Low-pass filter would be the natural solution, but you can also use a microcontroller to measure the duty cycle and use that value to control a DAC. To measure duty cycle you need a timer with input-capture capability. The higher your timer clock, the more accurate your measurement. If the microcontroller doesn't have on on-chip DAC you can use an extrenalexternal one.