what i do is usually pretty simple: create a new gradient map adjustment layer, choose your colors, and select a blending mode that works the best for your gif. then with a soft brush in black, click on the layer mask thumbnail on that gradient map layer and erase parts where you don't want the color (like on characters). if the character is moving you can use keyframes, here's a good tutorial by @usergif / @fionagallaqher explaining keyframes for masking.
with the gradient map adjustment layer, you usually want the first color of your gradient to be black, and the second color to be the actual color you want.
you can leave the blending mode to normal/pass through if it works for you, or you can change it to color (or try other blending modes, see if it creates and effect you like). here are a few examples with the same black to pink gradient:
for this particular gif here, i've actually used a gradient fill layer because i wanted a gradient instead of one color. but i did the same thing: i chose my 2 color for my gradients, changed the blending mode to color, and erased the layer over his body with a layer mask. what's cool with the gradient fill layer is that you can use as many colors as you want, and you can also choose the actual angle of the gradient, compared to with a gradient map layer where you pick the one color and that's it.
the downside with the gradient fill layer is that the math is not the same as a gradient map layer, so it pretty much only works well when you choose the color blending mode. as you can see here it looks wacky with the same blending mode examples:
there are multiple ways to change a background, this is just two of them. here are more tutorials about changing a background's color: