Yeah, I had exactly this problem before. I tried to wrap my head around how to actually do it geometrically, but thankfully had the much easier idea of just using the blend op.
This is super useful though! You don't always have the ability to change the blending op, or you could be rendering on top of something that might give you artifacts. Thankfully I was rendering something like this on a blank canvas.
That depends on whether you're drawing to a (temporary) buffer with alpha or drawing directly onto a background. Even if you can, it imposes limits on your overall compositing/drawing order.