I 3D print a tray that is just big enough to put the piece of electronics in it and deep enough to make sure that the electronic parts are completely submerged. And then I mix up some slow cure epoxy resin like US Composites and then pour it in. Let it sit for a day.