There are a number of different caps for sealing the top of soil mosture sensors such as https://www.aliexpress.us/item/3256805016615880.html. I created this one for my “Garden133” project (https://selectiveappeal.org/posts/garden133/). Spread a thin layer of silicone on the inside surface of the top and bottom part of the cap, insert the soil moisture sensor with the wire connected, and close with 4 M3x8 button-head screws. The cap will hold the JST connection in place to prevent disconnection when the wire is pulled on. The inside of the cap closely matches the shape of the sensor so very little silicone is required. I print this with PETG.
The stl files are generated by OpenSCAD sources in the Garden133 GitHub repository (https://github.com/chl33/Garden133/tree/main/OpenSCAD/SoilMoistureCap).
The author marked this model as their own original creation.