FIltering a PWM signal?
You are thinking of a solution that is inappropriate. Filtering a PWM signal requires only low pass filtering and not envelope detection and certainly not the 2nd circuit you have shown.

For simple filters use a resistor and capacitor in series across the PWM output to ground. The capacitor is grounded and the common R and C node voltage has the filtered output. A more sophisticated filter might be based around an op-amp 2nd order filter and this is akin to replacing the resistor with an inductor.

Higher order filters give improved results i.e. smaller ripple voltages due to the unmodulated PWM frequency.

If your modulation frequency is 100Hz try making an RC lowpass filter with a 3dB cut-off at about 200Hz. There will be some attenuation of 100Hz signals (maybe 1dB) and if this is too much progress to an op-amp (or inductor) 2nd order filter.