I've only run out of fuel once when I calculated the fuel I'd have left over when I made it back to port would be about 5% (cutting it close) and suddenly ended up driving through heavy seas unawares for several hours. Needless to say I ran dry well before I made it to port.
However I remember submerging and making it back at an extremely slow 1kt after the battery ran out. I'm not sure which mod configuration this was but I definitely remember it happening. That 1kt even on the highest time compression took quite a long time. I had to surface whenever CO2 levels got too high.
So depending on what your setup is I'd try that. I figured it was realistic in that even though the batteries are dead manpower could suffice in either recharging them or manually turning the props? Maybe I'm wrong but I can't see how it's not possible in safe waters

(outside of Aussie port)
I decided to continue the campaign using that explanation. Of course I think a tug would've had come IRL.