Hi Benjy,
you would have to write your own script to do that, STAR does not have an option to do this.
However, an easier option would be to parse the two file simultaneously, since the .junction file has exactly one line per read for all the reads in the .sam file,
and the 10th columns in the .junction file contains the read ID - which is 1st column in the .sam file.
So if you decide to filter some reads from the .sam files, you can simply remove the corresponding lines from the .junction file.
Cheers
Alex