I see two ways to do this:
The "good" one would be to get a microcontroller, have it create the PWM and then send commands to it from say Matlab or whatever you want to.
The other option would the to simply connect the audio output to the input pin and hope for the best. If the PWM frequency should be in the range computer sound card can support, then you can create appropriate sound. Matlab should be capable of creating required sound and playing it. Another option would be to just make a fixed square wave with some for example audacity just to test if thins will work fine.