It would be possible without spending an overnight. If you want to take the actual Bernina Express do the following.
Take the 7:20 Regionale train to Tirano arrive 9:52, walk across the piazza to the RHB station and get the Bernina Express departing 10:03, arrive St Moritz at 12:36. You can have some lunch or walk around St Moritz. There is a continuation on standard train to Thusis at 57 past the hour and will follow the route of the "long" Bernina Express on the Albula Rail line which makes a lot of spiral turns as it descends to Thusis, passing over the famous Landwasser Viaduct. From Thusis, you get a bus that meets the hourly train and takes you over the San Bernardino Pass to Bellinzona where you take the EC train back to Milan. That will get you back to Milan at 19:35 if you spend an hour and 20 minutes in St Moritz, later if you spend more time there.
Remember, you do not have to take the actual Bernina Express. There are hourly regional trains that follow the same tracks over the pass. No Panorama cars, but the windows open for better photos and no "reservation fee". Look at the weather forecast and try to do it on a sunny day.