25kHz PWM signal to analog voltage (DC) using low-pass filter: Weird output

You must have the resistor value of 150 ohms or more or you'll burn out
the Arduino pin. That large a capacitance is effectively a short circuit so
the Arduino is putting out far beyond its absolute maximum current trying to
drive it.

Try 6.8uF and 1k ohm.