Chamonix is better done as a day trip if you rent a car and drive. Otherwise you need to take a bus or get a van transfer. The bus service is not all that frequent - abotu twice a day in both directions. OR you can make a large "circle tour" by taking the train Geneva to Martigny, changing here for Chamonix (at present this involves a temporary bus connection from Vallorcine to Chamonix but it is coordinated with the train's arrival and the same ticket covers it as well) and then a bus back from Cham to Geneva in the evening.
Train schedules - www.sbb.ch/en
Bus schedules - sat-montblanc.com/fr/…GVACHX_Ete.pdf
For Van transfer: www.chamexpress.com
NB Do not use Alpybus for this as they have had consistently poor reviews on the TA site. Chamexpress is a very reliable and well run company.
For Gruyères you can also make a circle (partly anyway) route -
Geneva to Palézieux, change for Bulle and Broc Fabrique. Visit Chocolate Factory which is totally fascinating and the chocolates are delicious!. Continue on to Gruyères by train or bus. visit Demonstration cheese factory and walk up hill to the village. Definitely visit the Château. Then to return to Geneva take the train to Montbovon, change for train to Montreux and catch a train back to Geneva from there. IF you can, go to the Château de Chillon near Montreux as well. But perhaps Montreux is best saved for another day trip in which case you woud have plenty of time for Chillon!!