The gaps you are talking about are probably places where the bulb seal is degrading. I would not recommend using spray foam, because that stuff is rigid when it cures, and the bulb seal is flexible. I think it's possible the rigid part could get sort of "caught" on something and would rip off, taking more of the bulb seal with it.
I honestly cannot think of any kind of flexible foam you could "plug" into those holes.
You could POSSIBLY attach strips of door insulation (the flexible foam kind that you can find at Home Depot, Lowes, Ace, etc.), to either the bulb seal, or, I'd try to attach it to the lower half of the trailer just below the "lip" that the bulb seal contacts when it's up. This insulation has an adhesive backing, and since it would not be subject to much stress on the bottom half, it might stay in place. As the bulb seal rose to contact it, it might possibly cover the holes you described.
If you did this, you'd probably need to do it from the inside, and first take off the trim strip that's on top of the lower half to gain enough room to do it. The trim strip is just held on with screws and you need to remove it from time to time to inspect and lubricate the cables and the pulleys under it. I think then, if you lowered the top about 6", you'd be able to reach the area under the lip.
Let us know if you try this and if it works.
Hi-Lo 1707T - Tire Minder TPMS on Tow Vehicle and Trailer, 300W Solar Battery Charger, Equal-i-zer WDH
2014 F150 Platinum 4x4 3.5L EcoBoost SCrew