For a 5 - 500 Hz PWM frequency range, with a PWM input signal having clean edge transitions, a simple microcontroller seems a reasonable solution. It should contain a timer and a digital-to-analog converter for output. Not many simple microcontrollers have built-in DAC - perhaps one of PSOC-4 types.
The timer is used as an incrementing counter, initialized to zero on one PWM edge, and incrementing until the corresponding alternate edge, whereupon count value is saved (C1), and re-zeroed. The next input edge completes one PWM cycle...the counter's value is saved once again (C2). The ratio of C1/C2 is scaled and written to the DAC.The PSOC-4 series is targeted for simple analog/digital crossover applications like this.
It is inevitable that one PWM period delay must be accepted as the minimum settling time for PWM period-chages.
simulate this circuit – Schematic created using CircuitLab
A DAC can be avoided with some extra effort. Many microcontrollers contain analog-to-digital converters. One general-purpose I/O pin can be used to charge a capacitor, whose voltage is monitored by the microcontroller's ADC. The I/O pin must be capable of normal High/Low as well as tri-state digital states. An op-amp (low bias current) buffer is required to keep the capacitor from discharging through the load.
Although a current source charging and discharging (charge pump) would be ideal, a resistor charging the capacitor is possible too with a little extra calculation of appropriate charge times.