Potting compounds are a science.
If you are just protecting some spliced wires, then hot glue may work if you do a good job. The worst situation is if the junction box is completely filled with water. If you do a complete job around each splice, then you might succeed. If there are holes, however, water will get in and be trapped.
If there is a PCB in there, then be careful. A hard and rigid potting compound will expand and contract with temperature, and often the thermal coefficients between the compound and the PCBA are different. The result is parts being snapped off the PCB.
The softest potting compound for a PCB is silicone. It is gentle on the components and does very well at temperature extremes. However, silicone doesn't adhere very well and will pull away from the surfaces it is stuck to, which will invite water ingress.
Typical potting compounds nowadays are urethane-based. They are a balance between the adherence ("stickiness") of epoxies, but has a bit of softness to be nice to the PCB components.