I have an extra half day in Salzburg that I would like to take the train to Werfen to visit the Hohenwerfen castle. I would be catching a train from Salzburg and arriving in Werfen at 2:15 and returning to Salzburg at either 6:15 or 7:15. Question, is Hohenwerfen and the sound of music trail doable in 4 hours?
It all depends on how thoroughly you want to "do" the castle.
In 2012, I spent most of a day at Hohenwerfen. I stayed in Freilasing, across the river from Salzburg and went by train to the Salzburg Hbf in the morning, not real early. I left my bag in a locker at the Hbf and took a train down to Werfen. From the Werfen station, I didn't see any public transportation up to the castle, so I walked through town to the castle. The walk was an easy mile (1.5km), slightly uphill. From the car park below the castle, I rode the incline up into the castle.
I took the tour of the castle, including the birds of prey exhibit and the castle itself.
After touring the castle, I walked back to the train station (mostly downhill), took the train back to Salzburg, retrieved my luggage, and went by bus to Berchtesgaden for the night.
I didn't do the SOM trail. If you do the SOM trail, I don't think you can spend much time in the castle, certainly not take a tour. If all you want to do is go into the castle courtyard, look around, and say, "Hohenwerfen Castle, check", I think you could probably do it and the trail in the time allotted. Total walking distance is probably about 3½ miles.