Speaking in terms of health for the ears and eardrums, would earplugs that form an airtight seal be dangerous to wear in flight due to cabin pressure changes? What about in the event of a rapid depressurization? And does it make a difference in which phase of flight they're first put on (before take off vs when in cruising altitude)?
I wear earplugs all the time flying in both pressurized and unpressurized environments, and have done it for many years. Air pressure changes have no noticeable effect when wearing foam earplugs as the interface between the foam and ear canal is not totally air tight. The silicone flanged ones made for airline flying have a tiny bleed hole in them (flanged ones are way too uncomfortable for me though).
If anything, on an explosive decompression, the earplugs would help by delaying the escape of pressure on the outside of the eardrum while the pressure equalizes on the inside through the eustachian tubes, which can take a second or two if you have to work your jaw to open them.
Put them in whenever you want and take them out whenever you want.
Emphatically yes, it is absolutely safe.
Before the advent of noise canceling headsets, all of my Air Force flying was with foam earplugs. I never heard a single caution of any adverse risk, whatsoever. ("Don't eat them," maybe.)
This was in both pressurized & unpressurized aircraft, including missions where we'd depressurize the cabin from 8,000' to mid/high teens for high altitude airdrops, and then repressurize afterwards. Earplugs were never, as far as I ever experienced or heard about, a cause of any discomfort.