But will it hold up to the types of chemicals circulating in an engine compartment? That was the downfall I found a couple times using "household" materials under the hood.
One I found that does hold up is a foam chinking for use between logs of log homes. It's a fairly dense foam rubber seal strip that comes in rolls. I copped several rolls left over from a job we did years ago, one is about 1" wide x 5/8" thick, the other 1/2" wide x 3/8" thick, with sticky on one side. I have used it in numerous places on both my old truck and my car and it hasn't degraded from sunlight, temperatures or fumes/chemicals.
And that just jogged my memory: I remember many years ago using soft thick walled vacuum tubing for making seals just like what you need. About 1/8" interior diameter size, but close to 3/8" OD, it was softer than oil or fuel lines, for use on engines. I slit it and glued it on the metal edge with silicone sealer and clamped a lid down on it.
And looking at your photos again, as it appears to me, wouldn't just flat 1/8" or so thick rubber gasket material glued (or even riveted) to the flange of your box work to seal the lid?