Your question led me to look at two maps:
In this map and the next one, switch back and forth between the aerial view and the map view to get a full impression.
In that first mapsearch.ch map, there are icons for the train station and the bus stops. Mouse over the icons for the bus/train route numbers. You also get the exact official name for the station/stop, which you can use in the SBB timetable to set start and destination locations and get travel times and times/schedules
You will see that it is about a 1 km walk by a twisty road from the train station to the medieval town and castle.
What is not clear from that map is the altitudes. However, the twisty road is a clue that there is a hill.
So, I looked at this much more detailed topographic map, which shows altitudes:
map.geo.admin.ch/?topic=swisstopo&lang=e n&bgLayer=ch.swisstopo .pixelkarte-farbe&catalogNodes=139 2,1538,1396,1430,1436& layers=ch.swisstopo.sw isstlm3d-wanderwege&E=2572300.5 9&N=1159149.97&zoom=10 &layers_visibility=fal se
The train station is at 746 meters altitude. The castle is at 830 meters... an 84 meter climb. The town is a bit lower than the castle itself, which is at the highest point.
Both maps show about a 1 km walk from the station to the town and castle. In the second map I have turned on "hiking trails." It thus shows a trail route which does not follow the road, and has a good part of its climb close to the station
The trails are yellow, which means they are not rough surfaces and do not require special hiking gear or boots. You may turn them on and off in the menu.
Although the altitude number is not shown, by using the topographic map's contour lines, I can see that the last bus stop is at about 80 meters. So, the bus saves you about a 54 meters +/- climb and most of the 1 km walk.
If you like a little bit of exercise, walk. If you are comfortable with the wait for the bus, and don't want the climb, ride. The bus schedule will be posted at the train station. Often, that sort of shuttle bus is timed to match train arrivals, so , if you think you want to ride the bus, make sure to look for it and go quickly to it when you get off the train.
Gruyeres will be full of tourists, but is still a very nice place to visit.