From the Home Shop machinist forum:
First off make a shallow wooden box that is deep enough to hold your items and a neat fit inside the drawer or tool box. Thin plywood is plenty good enought for this. Drill holes, 1/4" or so at 2" grid spacing over the bottom of the box.
Get some knitted cotton as used to make t-shirts, the colour is your choice. Carefully spread this loosely over the top of the box and glue it down the sides. It must be secure and avoid wrinkles. Spray it lightly with water and set aside, you want it damp(ish) not dripping wet.
Now get your treasured items and spread them on a flat surface arranged how your prefer. Cover them with a layer of cling film but leave it slack.
Now, turn your box upside down and place it over the items and reach for your can of expanding polyurethane foam. This is the stuff they sell for filling gaps around draughty window frames etc.
Inject foam into the holes and squirt it around to ensure the space above your items gets really filled and you dont want any voids. Pretty soon it will start oozing out of the holes so slap a sheet of metal, board or whatever on and weight the whole business down. If you used thin plywood you should brace the sides as there is quite a bit of pressure exerted by the expanding foam.
Now relax, tomorrow you will have a nicely formed insert for your tool drawer (in the colour of your old t-shirt).
I specified putting cling film over the items but I have never found this necessary, and I have made a few inserts for optical items in my telescope cases, as the foam does not penetrate the knitted cotton. Dampening the fabric accelerates curing of the polyurethan and it might be what stops the foam pushing through the fabric.
Note that because the items were put on a flat surface your finished drawer insert will provide a flat top surface even when the items are in place giving the possibility of stacking inserts, but I have never done this.