How to tell a boosting model that 2 features are related and should not be interpreted stand-alone?
I am going to talk about some ways you could do it later but first I want to talk about whether you should!

If the relation that you describe exists XGB will be able to learn and detect it! There is no real benefit in "hard-coding" a rule into the algorithm, it won't speed up the training, it won't benefit accuracy, etc. Simply put the benefit of ML algorithms is that they are able to detect exactly these relationships and model them in the best possible way.

Now if you still insist that this is something that must be done, you can. The easiest way to achieve this would be feature engineering:


Introduce NAs -simply leave out hair length of male respondents and fill with NA
Create interaction factors - instead of having hair length and gender as a simple variables you could also code it in a way that represents the known interaction like this:


gender_hair = [male, female_short,female_medium,female_long] # example factor levels


But again if you compare models with those engineered features to a simpler model you will see no benefit I'd wager.