You're in luck. From Lugano you will take a scenic train now matter how you go.
Go to https://www.sbb.ch/en
Now the fastest way, may be to go to Milan and turn around and go back to Switzerland. If you have a Swiss Travel Pass or Half Fare Card, it will not be valid in Italy and you will have to pay extra, plus not that scenic. There are 2 other routes that will get you to Zermatt.
To make sure you see them, in the "Via" box put in "Goeschenen". You will take a train north (which is scenic) and at Goeschenen a short train to Andermatt. From there take a train to Brig, then change to a train to Zermatt. The train from Andermatt to Brig is on the Glacier Express route. If you did happen to get the Glacier Express there, it will take you all the way to Zermatt, but you will have to pay the reservation fee.
Another route is to put "Locarno" in the "Via" box. That will show a train to Locarno, perhaps with a change along the way. At Locarno you will change to the "FART" (don't laugh), aka the Centovalli railway. "FART is an acronym, but this is a famous scenic train to Domodossola, Italy. Even though it does go into Italy, the Swiss Travel Pass and Half Fare Cards are valid. At Domodossola, it arrives at an underground station and you go upstairs to the main rail station. There you can get a train through the Simplon Tunnel to Brig, and at Brig change to the train to Zermatt. This train is actually out in the street outside the main Brig station.