In the sentence, "my dog ran up to me, wagging its tail," does "wagging its tail" modify "dog" or "ran"? Does rewriting the sentence as "wagging its tail, my dog ran up to me" change anything?
This is called a praedicative adjectival phrase; that means that it has an adjectival form and syntactically it mostly modifies the noun (my dog), but semantically it tells you something about both the noun (my dog) and the verb (ran). This is often the case when an adjectival phrase comes after the noun it modifies. Other examples:
She arrived first.
She became mad.