On the trains, yes. Takes about 1 hour + a little more with one change of train.
If you stay in B'gaden you are eligible for a local transport ticket - the visitors card:
This card provides for partial coverage of the fare on that bus. I believe the additional fare to complete the trip to Salzburg is a couple of Euros.
There are some time limitations if using this ticket on weekdays (but not on weekends). You can’t use the Bayern or Navaria ticket before 0900 during the week.
Bayern Ticket covers also bus line #840.
But if you stay overnight in Berchtesgaden it will be cheaper to use the extension tickets in combination with your guest cards. To my knowledge EUR 5,00 pp.
This ticket covers however the 840 buses, no the trains. It has no "from 9am only" restriction on weekdays. But the last 840 bus runs early in the evening, while the trains would allow you to return much later to Berchtesgaden.
The above tickets do not cover local public transport in Salzburg. A 24 hours ticket for Salzburg is EUR 4,00 if you buy it from a ticket machine or online.
"Bayern Ticket covers also bus line #840"
(Oh - My bad - thanks for the heads up abalada.)