I looked this one up in both manuals but I found nothing

I want to overlay a shape onto a sphere such that the surface of the overlayed shape matches the contours of the sphere exactly at the layover point. Thus if you overlay a 2D rectangle onto a sphere, you get a 3D part that has a smooth curved surface matching the surface of the sphere at the layover point

I think this has something to do with “gluing” but I can’t figure it out

It’s really a variant of the Sandbox Drape operation ?
If you want to have the ‘draped’ geometry separate from the Sphere, then reverse part of the steps, selecting all of the ‘box’ so the intersection lines appear on its faces - then erase the unwanted geometry forming the rest of the box so you only have the ‘drapes’ edges… Xray-mode [or a temporary Section-Cut] will allow you to look inside the Sphere to delete the inner unwanted ‘box’ edges…