Hot melt adhesive is pretty waterproof and if you have it available I would carefully paint the magnet with the hot melt. You can re-flow the glue with a hair dryer or gas lighter to smooth the surface if you are very careful not to get stuck to the molten glue.
A quick fix might be to put petroleum Jelly/Vaseline/Silicone grease into the bag with the magnet. These will repel water and keep the magnet dry.
Heat sealing the bag with a cheap dollar store food bag sealer should help, sort of like the expensive bag sealer from Staples.
Nice method would be to purchase a length of suitable diameter heat shrink tubing, preferably with the inside hot melt adhesive. If the tubing has the adhesive you can shrink it and press the ends shut when everything is soft and sticky, use books or wood blocks so they don't melt or burn you. If your heat shrink does not have the adhesive lining you can use your glue gun to place a generous bead of hot melt glue at each end of the magnet, when cold slip the shrink tubing over the magnet and re-heat with the hair dryer/hot air gun and proceed as above. If you leave a tail on the tubing you can use it as an attachment point.
A small plastic pill container may serve the same purpose.
An alternative is to use painted (or plastic coated) coathanger wire and wrap a bunch of turns around your bottle and not care if it rusts, just replace it with the new bottle and attach the magnet in a protected place so it does not remain wet.
EDIT:
One idea that might work is to drop some small chromed steel ball bearings into the shampoo bottle. Then pull them to a convenient place with a external (waterproof) magnet. You then just need to have a suitable iron spot to park your bottle. When the shampoo runs out you can recover or throwaway your ball bearings.