The cheapest option would be by bus but there is no direct service. You need to change at Poggibonsi just as with the train/bus route you have to change at Siena.
To Poggibonsi the line is #131 and there are departures at 07.10, 08.15 and 08.40 arriving at Poggibonsi at 08.00, 09.05 and 09.30 respectively. From Poggibonsi to San Gimignano the line is #130 with departures at 08.32, 09.15 and 10.20 arriving at San Gimignano at 09.00, 09.35 and 10.40 respectively.
If not too early the 07.10 bus looks the best bet in terms of connection time. The cost of the bus tickets should not exceed €8 in total.
Return buses from San Gimignano have departure times at 16.55, 17.14, and 18.35 for example.