First off, I should emphasize that I'm not dealing with absolute grammar here. Whether a modifier is
fundamentally a verb or a noun modifier is a question I'm happy to leave to academic grammarians. My focus is on a method to solve GMAT problems that is easy to master.
In our materials we describe present and past participles, when set off by commas, as adverbial modifiers. I.e. they modify the whole clause, often providing an explanation or consequence of the action they modify. An example is 'I broke a window, making my dad angry.'
We need to remember, however, that grammar is a set of guidelines to conveying clear meaning and that most grammar rules have some grey areas. I think you've found these, but a couple of examples of controversy of this rule are SC 719 from OG 2018 and the problem discussed here
https://www.manhattanprep.com/gmat/foru ... t8474.html (these are official problems, and I'd only trust looking at official problems to check a nuance such as this one).
On one reading, the modifiers in the sentences referenced above seem like noun modifiers. However, on closer inspection we could just as well describe them as adverbial modifiers. The area that the Caspian Sea covers explains why it's the largest lake on Earth, and the view of the policy makers explains the experts belief. On either reading the modifiers work and I'm happy to shelve this debate.
What's important for such comma -ing modifiers is that there's a connection between the actions. In your example
Sam, graduating in just three years, took extra classes in the summer. there's definitely a link between the graduating and the taking extra classes, so I would say that it's okay. Sure, placing the modifier in the middle of the sentence seems a little strange, and part of me wants to make it
Sam, who will graduate in just three years, took extra classes in the summer. We might as well say
Graduating in just three years, Sam took extra classes in the summer. I would say that all these variants are possible. Perhaps, though, the meaning would be clearer with one small adjustment:
Sam, hoping to graduate in just three years, took extra classes in the summer.What we have to watch out for are much more crude errors. I couldn't say
Sam, loving ice cream, took extra classes this summer. as these are just two random facts about Sam. For that, this construction would be preferable:
Sam, who loves ice cream, took extra classes this summer.