Testing an oscilloscope with my Arduino
You can convert the PWM output of analogWrite() into an (approximate) analog voltage by adding a low-pass filter. That is, a resistor in series followed by a capacitor to ground.

The values to choose depend on the frequency response you want. 


RC Filter Calculator (second section).


For anything more complex or accurate you will need a DAC. I often use the MCP4822 SPI DAC chip.