A rear-rack trunk bag can actually work really well if you control vibration, and the DIY route you’re considering is a perfectly legit solution.
For what it’s worth, I ended up doing something similar: I lined a trunk bag using some tool box foam inserts I had left over from another project...