its not so much the seal of the butt cap, i think its letting water in where the receiver bolt goes through the butt stock, which is impossible to get at.
It would probably work fine as long as you made sure the foam was able to expand without warping the stock. I've seen walls around windows bow out due to to much foam being used and nowhere for it to expand. You could also use wet paper towel to stop expansion. Have it ready, cut to the shape needed, then put in place after you spray the foam. Squirt it with a spray bottle when it's near the size/shape you want. Assuming it's a large enough cavity I'd look at using wet paper towel to outline the bottom and sides, then fill the centre with foam so you could remove it if needed and/or shape it. Also won't ruin the rifle if you don't like it.