Can I fill the void behind the shelves in a tub surround with polyurethane spray foam for added strength?
I can share some experience and advice here...


don't put anything hard in the shelves - like a bar or wood in the shelving void.  The house will move, the tub will move and this will move any type of insulation you use in addition.  Pretty soon you will have a shelf that is awkwardly hard in some area and soft in other and possible bulges.
do put insulation in the shelves
do put insulation in all of the other voids in the tub surround


Great Stuff is actually the exact choice you want if you are going the spray foam route.  You will want to tape the back of the shelf section (duct tape) after.  That is to ensure the spray foam doesn't move too much.  Also you may want to quickly sand the inside with a rough grit to allow better bonding.  If your fiberglass is thin you want to go spray foam.  The drawback of the spray foam is that under heavy stress and time the spray foam can break off from the shelf and then potential move a lot.  Shelf will still be sturdier but may make a little noise.  And that is really the negative with spray foam - you have the chance of hearing a rubbing noise after wear.

I really really suggest filling large (non-shelf) voids with fiberglass batts.  I lay the fiberglass all around the tub, I pack it in huge voids, and fill (pack) shelves with it...  I fill shelves if I believe that particular fiberglass is thick enough to handle the extra weight (I know it isn't much).  I will generally try to use fiberglass because it isn't noisy and gives the fiberglass a soft marshmallow feeling.   I would also tape the back of the shelves with the fiberglass so it doesn't fall out.  

IMO this is a huge upgrade done for $40.