Keep the foam—it’s a critical thermal break and weather seal, not just a filler. You shouldn't aim for a flush fit; you need a 3–4mm gap between the skylight and the upstand to allow for thermal expansion and contraction.
If the unit sits directly on the lead, differential movement between the...