As was mentioned, you can record MIDI notes by playing a real keyboard (or MIDI controller) that's connected to Sonar or you can enter the notes manually with the mouse in the Piano Roll View.
I don't know of a way to actually record the soft synth in real time, but, once you have the notes in the MIDI track you can "freeze" it using the "freeze" button. This will create an actual wave file of the MIDI track. This is better than real-time-recording because if you need to go back and make changes to the MIDI track you can just unfreeze it, make the changes, and then freeze it again.
You can then "Bounce to Clips" which will make it more permanent.
Steve