If it were me (and I'm only a DIYer) I would fix a cut piece of plasterboard to what looks like that wooden lintel and then skim over that. The plasterboard would provide a much shallower surface for a filler to bond to.
If there's nothing there to fix to or if you don't have plasterboard, can you access it from the loft? Or can you maybe slide a piece of ply into the hole and fix this in place with a screw.
Don't use foam it'll be a mess and end up everwhere.
I would recommend expanding foam. Spray a mist of water first and slowly squirt in foam. A foam gun would be easier to control but not required for such a small area. It can be done in more than one hit if required.
Yeah, some may drop down to the floor- put down some polythene sheeting, it wont stick to that.
If applied properly, hopefully, the foam will lock the existing plaster in place.
Cut away the excess foam, slightly undercutting, and then use filler over the top.
Before doing that, I would recommend cutting away the massive bead of caulk. I am guessing that you (read: the OP) had a textured paper on the ceiling.
I can not understate the ability for expanding foam to "lock" substrates.
Tomorrow, I have to deal with a (Victorian) stair string than constantly cracks at the bottom of the stairs where it meets the skirting. I plan to drill a series of holes and the squirt in foam to lock it. Additionally, I will use a flexible epoxy resin to fill the mating gap.
I would like to add a bucket load of screws through the strings (to the wall), but I have no idea what is behind the plaster. If I drill a lot of holes, just through the string, and not through the plaster, I hope it will lock the wall side of the strings for a few years.