I get what you're trying to do, but your request actually lacks some important details. For instance, what kind of microcontroller do you intend to use? It's rather difficult to point you at some code, if we don't know what kind of CPU you're using. You also don't specify what you want the amplitude of your sine wave to be, or how much current you need to source, and that matters quite a bit as well. Temperature stability is also a concern, and you didn't mention that either.
The general idea, assuming you have some dedicated pins on a data bus you can use, is to set a bit to 1, wait half the period, then set that same bit to zero. For 2KHz, the period is 0.5 mS. So set the bit to 1, wait 0.25 mS, then set the bit to zero, wait 0.25 mS, and repeat the process. You could use an on-chip counter timer to trigger an interrupt to tell you it's time to change the bit value, assuming your CPU has one. That will allow you to avoid writing a delay loop for the timing. The benefit of not using a delay loop, is your timing becomes independent of the processor clock speed. Doing that gets you a square wave with a frequency of pretty close to 2 KHz. You could also use a D-type flip flop, and strobe the clock line on the flip flop once every half period.
If your processor has an on-chip D/A converter, you can simply cycle values to the D/A to generate any waveform you want. How many updates you do to the D/A value within the desired period of the output waveform will govern how close an approximation to an actual sine wave you get.
Now you want it analog, and low distortion. Well, since the square wave is the fundamental frequency plus all the odd order harmonics, all you have to do with the square wave you've generated off a data pin, is filter out all the harmonics. Since we're working with an audio frequency, there are lots of ways you can do that. Basic choices are an active analog low pass (or band pass) filter (op-amps), or a passive analog low pass (or band pass) filter. Use care in the component parameters you choose to ensure temperature stability, because as the temperature changes, so will the component values for the parts you use, which will cause the cutoff frequency of your filter to shift as the temperature changes. Pick your filter cutoff frequency to be slightly above 2 KHz if you're using a low pass filter, so you can avoid the 3dB point on the filter roll off. You might need more than one stage in cascade to improve the Q of your filter and make the roll off steeper. The benefit of using op-amps, is you can give your filter a little voltage gain to keep the amplitude where you want it, and overcome any insertion losses for the filter. If you use a passive filter, you're going to lose a little amplitude due to insertion losses of the filter. Overcoming the insertion loss will require an amplifier with a little gain anyways, so you might as well cut to the chase and go with the active filter method using op-amps in the first place.
If you chose the D/A converter method, you're still going to have to filter out the harmonic content.
You mention ramping up the waveform. Not sure what you mean by that. The rise time of a 2 KHz sine wave from zero to maximum is going to be T/4, or 0.125 mS. That is well within your 3-5 mS limit. Or, do you mean modulating that 2 KHz sine wave with a triangle wave, to cause the peak values of your sine wave to rise and fall in step with the triangle wave.
Hope this helps, at least a little bit.
73 de N8AUC
Eric