Print the main parts (thing and socket) out of PLA or other hard filament you like, the lid should be printed from flexible filament like TPU.
You need some force to get the joint working, after this is done, the joint works very good.
This thing is completely designed in Freecad, feel free to add some additions, like a lock, so the clip seen in the image is not needed.