Can XGBoost do classification based on linear combinations? Suppose we have a data set $\mathcal{D}$ consisting of $n_C$ continuous features $\boldsymbol{X}_1, \boldsymbol{X}_2, \dots, \boldsymbol{X}_{n_C}$ and we wish to target a discrete variable $\boldsymbol{X}_D$ which takes 4 levels based on some linear combination of the continuous features. For simplicity, assume that $X_{i,D}$ is based on the value of $X_{i,1}+X_{i,2}$ (where $i$ refers to the $i$th observation) (e.g. if $X_{i,1}+X_{i,2} \in [a,b]$ then $X_{i,D} = 1$, if $X_{i,1}+X_{i,2} \in [c,d]$ then $X_{i,D} = 2$ etc. with $[a,b]$ and $[c,d]$ disjoint even, for simplicity). Would an XGBoost classifier be able to detect this relationship and build a classifier targeting $\boldsymbol{X}_D$ that uses all continuous features as predictors (obviously any other feature besides the 2 determining the relationship will be given an almost 0 importance)?

Yes, absolutely! XGBoost or any other gradient boosting machine implementation (LightGBM, CatBooost, etc.) would work fine. Approximating, a purely linear function by recursively partitioning our sample space using tree-based learners can require training a large number of base learners (i.e. doing a lot of "iterations") but aside from that it is nothing "too exotic".
seanv507's suggestion with LightGBM 's linear treee base learner will likely require fewer iterations (i.e. using a smaller number of base learners)  as we will have a model at each leaf that is linear instead of constant (i.e. it should capture that linear dependency more naturally/efficiently). Finally, to state the obvious, maybe using a different learning methodology (e.g. Elastic Net) might be more suitable if have known linear patterns dominating our underlaying data-generating mechanism.
