In traditional grammar, the word doing is a participle in all your examples. It modifies the subject, I. This can be made more visible by reversing the word order, which results in a somewhat artificial but transparent sentence with identical meaning:
Doing my homework, I spent the whole evening.
Your construction is the same as in these sentences:
I hurt my hand repairing the car.
I left the house running.
A participle often expresses the circumstances in which the subject performs the action of the finite verb; that is why you can often replace it with a while or because clause, an adverbial constituent of time or cause:
I spent the whole evening because/while I was doing my homework.
A feature of English (ellipsis) is that we can sometimes leave out the subject and the form of to be. In this case, that is possible with while if the subject is the same as that of the main clause and the finite verb is a form of to be. Then we get this:
I spent the whole evening while doing my homework.
But this elliptic clause is still quite different from the participial construction in your examples; notice how the ellipsis is not possible with because.
Now let's consider your first example:
I felt good doing my homework.
The fact that my homework is also felt to be identical to the thing you feel good about is accidental, it is a red herring: the construction is exactly the same as in I hurt my hand repairing the car, where repairing the car is in no way the thing you hurt your hand about/in/whatever.
One could add a preposition in your first example:
I felt good about doing my homework.
But that doesn't prove anything: the word about cannot normally be left out in English, so this is an entirely different construction. The fact that there is little change in meaning is, again, a coincidence rather than a structural feature.
In this construction, doing is a gerund (not a participle), because it functions as a noun. Only things that function as nouns can be the object of a preposition. You can see that it is not possible in other instances of the same construction, which shows that doing is no gerund here:
*I spent the whole evening about doing my homework.