Combat digging is called 'sapping' and is a part of actual real-life anti-castle warfare. Medieval sappers used a variety of tools to undermine fortifications, but moving loose earth was a significant part of the process. While mold earth is certainly not sufficient to undermine a fortification-- pickaxes and explosives being required for a lot of the work-- it should certainly help with a sapping effort.
Furthermore, besieging forces used saps extensively to mitigate defensive artillery and arrow fire while advancing their own siege weapons so as to deal more damage to the defending walls. These saps were not underground tunnels as with an undermining effort, but rather trenches and embankments such as one might picture on WWI battlefields, zig-zagging towards the fortification to attempt to avoid allowing the defenders to enfilade effectively. For this kind of sapping, mold earth is perfect; there's no need to mine through stone or hard-packed sediment.
Regardless of the strategy chosen, however, be aware that assaulting a castle is a dangerous business. Even with a carefully planned sap, fortification designs like the Italian Star Fort can ensure that defensive fire poses a real danger to would-be-besiegers, and undermining runs the danger of being ambushed by counter-miners.
Also, the portable hole is a waste of time and resources. There are far better uses in warfare for such a powerful artifact than to shovel dirt in a manner more efficiently done via Mold Earth itself or a line of untrained laborers or men of the line. Furthermore, you usually don't want to move the dirt very far unless you are undermining; embankments about your trench are an important part of granting yourself cover.