Yes, absolutely. I have done it before and it was a lovely experience. Saint-Tropez is worth visiting even if just for a day. For a day trip to Saint-Tropez from Nice by train, take the first train to St-Raphaël (7.01 am) and then take the bus or a taxi to St Tropez.