How to do it depends on the kind of output you want and how advanced you want to go.
If you want to track well behaved repeating waveforms with only two zero crossings per period and possibly asymmetry in the half periods, you can count the half periods and generate sine half periods accordingly, although there will be some jitter in the output since only integer half periods are used. If the input waveform has multiple zero crossings per half period, this method doesn't work too well since the reconstructed waveform lags the input by one zero crossing. For an arbitrary source signal all bets are off.
The situation can be improved (again depending on what output you want) by pre filtering the source signal if you don't need to track more than two zero crossings per period. You can also simply take the sign of the source wave (as the matching square output) and low pass filter that to approximate a sine wave.
You could also measure the frequency of the fundamental, but then you will not be able to track asymmetry in the half periods or multiple zero crossing per half period, so again it depends on what kind of output you want.
I've attached an experimental patch with a simplistic embedded "sign_wave" object to play around with this based on the above techniques. It has some controls on the left hand side to let you play around with different source signals and enable pre filtering. The sign_wave object also has one control to control sine half period overshoot. The top row of oscilloscopes shows the various outputs, the bottom row shows the source signal. Regarding pre and post filtering; if the pitch control for the source signal is available you could use that to make the filters track the frequency of the source (can be done in the attached patch by connecting the pitch control to the filters pitch inputs).
Somebody else can probably give you a much more clever solution - this was just an experiment made because your posting made me curious.
test_sign_wave_embedded.axp (9.8 KB)