It probably could be 3D printed, the problem is winding the transformer and potting it, so it doesn't arc over. It has to be wound in a careful manner, to ensure the voltage between neighbouring wires doesn't exceed 500V, or so and potted with resin in a vacuum to exclude air pockets. Everything must be kept clean and free from moisture, salt and greese.
You could even just use the box as a mould and remove it, after the potting has cured, but you need to ensure that there's enough space between the windings and the mould, so they don't poke out, when it's removed.