You can train the entire way but it would require you to travel through Bari which is in the wrong direction from Salerno.
If you really want to:
1) Take the narrow gauge train (privately run not Trenitalia) from Matera to Bari
2) Connect to Salerno from Bari changing either in Caserta or Taranto (or through Naples for multiple transfers) but the fastest looks like 4 hours and usually more
Taking only the train seems like a 5+ hour affair but is doable.
From a quick search the only bus combo I've found that seems bookable is Matera to Taranto by bus (1 hour) and Taranto to Salerno by train (3 hours 40) which isn't great.
Hopefully there are better options out there, but it obviously can be done.
Good luck,
=Tod