Whatever input Audacity is using to "hear" the guitar, a Sonar audio track needs to be set with that as input. Output to Master as usual.
To hear the guitar you also need to enable the "input echo" switch on the audio track. It looks a bit like (((. That will pass the incoming guitar back out to your interface after passing it through any plugins on that track via the master bus. The volume of the guitar's return is set by the volume slider on the audio track.
After which, assuming your system's round trip latency is low enough, that should be it.
One thought on latency. Some plugins require huge latancy to do their job so Sonar slows everything down so they can keep up. Convolution reverbs and compressors with look-ahead functions are the main culprits. If you insert a plugin and all of a sudden there's a big wait between playing and hearing the guitar when everything was fine before, you've probably just found a plugin with high latency requirement,