On the Xbox companion app, on the right side, at the top of the screen, it says find people or clubs, here you can type in the gamer tag (it needs to be 100% accurate, capital letters and everything) then just click add friend.
On the new Xbox app, the one that hosts gamepass, you need to click on social, on the top left of the screen. Then type the gamer tag of the person you are looking for in the “search for people” bar (here capital letters don’t matter) then click on the person and click follow.
On Xbox it should work the same as in the new Xbox app, but i would need to confirm that on my sons Xbox.