Great Stuff used to make a black expanding foam for landscaping (like garden ponds and such-- my dad has used it in his), but it appears they don't anymore. Reading the Great Stuff site, however, they do specifically recommend painting the foam in applications exposed to sunlight.
I have, however, found this:
Pur Black NF Expanding Foam - Foam Products - Pond Accessories
It seems kind of pricey, but is meant to be used outdoors, and will allegedly withstand heat, cold, moisture, and light.