Is this possible and what would be the best way to go? How long of a train ride?
Where in Switzerland? If you have no specific place in minds, one of the good options from Varenna is to go north to Tirano and catch the Bernina Express train over the mountains. To Pontresina it would be 4.5 hours by this route. If you are doing this as a daytrip it makes a long day. Or if you just want to step on Swiss ground, you could cross the lake to Menaggion and take a bus from there to Lugano, on the lake. It is Switzerland, but it feels more like Italy.
Lola, I did fail to mention, it's Zurich that we're heading to. Flying into Milan and wanted to go to Lake Como area on the way to Zurich.
Jo, Yes, it's absolutely possible! My preferences on that particular route would be a train departing Varenna-Esino at 07:37, arriving Zürich at 12:51 (time 5H:14M, one change at Milano Centrale, reservations compulsory for the Milan-Zürich section, which is direct). The schedules may change slightly between now and when you'll be travelling, but I suspect they won't change much. Will you be travelling to Zürich city centre or to the airport on that particular trip? Happy travels!