First of all, there no legitimate genetic basis for the concept of race. That's important to understand. There would be no rigorously scientific way to enumerate all of the races, for example, because there is too much crossover and confusion and there are too many edge cases. Everyone is their own unique mix. Race is best understood as a cultural construct that we create based on the way groups of people tend to look at first glance and the roles those groups of people play in our society.
Traditionally race is defined by whatever race your family appears to be. If you appear to be a different race from your family through genetic variance, you still supposedly inherit your race from your parents, whatever that may be.
It isn't all that uncommon for children to appear to be of a slightly different racial mix than their parents, even though genetic testing can prove legit parentage. Recessive genes are weird like that sometimes.
There have been historical cases where people tried to change their official racial definition in order to negate social disadvantages, such as when black Americans who had children that could visually pass as white tried to do so during the Jim Crow era. But unless it is done in the name of social justice, trying to hide the most honest version of your racial history is generally frowned upon.