there is no 100% foolproof way to protect rooted hair when painting. you can wrap the bulk of it in saran wrap, tin foil, something else, some combination, etc
then just be super careful with a tiny brush near the roots...but chances are you will get some paint on some of the roots.
take the tail out if you can...otherwise same deal