there are (were) 2 companies in CT that did this kind of work. took me awhile to find them
my idea was to kill 2 birds with 1 stone! since the plastic lining that lies under the roof tiles rotted away many years ago and was causing minor problems with leaks, not to mention the costs of removing all the tiles and redoing the roof lining - I wanted the spray foam to cover & seal the tiles underneath permanently and provide thermal insulation.
1 company took the time to came and inspect my roof and bring samples of their foam product. the problem was that both companies made it clear that since it was extremely difficult to get their equipment into the small space in my roof and the fact that they will NOT spray directly onto the bare roof tiles for fear of cracking the tiles in summer. the idea was abandoned and I found roof insulation with a tin foil backing that prevented minor drops of water getting onto my ceiling thus solving the problem.
if you are building a new house or an edition then they will come spray foam before the ceiling is installed.