The function of the phrase "hoping for a few scraps of food” in the first sentence is It is a participial phrase that modifies “puppy.”
The participle phrase starts either with the present (dependably ending with -ing) or past (dependably ending with -ed)
The participle phrase includes the modifiers or objects to complete the thought of the sentence. For instance, in the above sentence 'hoping' is the present and modifies the word “puppy”. Therefore, the participle phrase acts as an adjective always, providing a description of the sentence,