Can a completely drained battery be recharged via ground power on an airliner like the B737? When accidentally leaving the battery switch or something powered by the hot battery bus on over night, an aircraft's battery could completely discharge. Normal startup, where the battery is switched on first and then external power is connected, would no longer be possible.
Is it possible to somehow connect an external power unit to the aircraft such that the drained battery is being recharged? Or would maintenance have to swap out the battery or charge it in some other way?

Details for the Boeing 737 are below, but answers for other airliners are welcome:
On the Boeing 737 NG, the batteries are charged via their own transformer rectifier units:

Battery Charger Transformer/Rectifier
The purpose of the battery chargers is to restore and maintain the batteries at full
electrical power. The main battery charger is powered through AC ground service
bus 2. The auxiliary battery charger is powered through AC ground service bus 1.


(Boeing 737 NG FCOMv2 6.20.12 - Electrical - System Description - DC Power System)
These ground service buses can be turned on independently of the main aircraft AC buses:

Ground Service
For ground servicing, a ground service switch is on the forward attendant’s panel.
The switch provides ground power directly to the AC ground service busses for
utility outlets, cabin lighting and the battery charger without powering all airplane
electrical busses. The ground service switch is a momentary push button and is
overridden when both AC transfer busses are powered.

(Boeing 737 NG FCOMv2 6.20.2 - Electric - System Description - Electrical Power Generation)
This sounds like the battery chargers could be powered via ground power in ground service mode. It is however not clear to me, if this push button would even work without any battery charge left.
My one experience with this was in a 737-300 that had the battery charger die, and the battery depleted while in flight.  The Battery Bus was still powered by TR3, but the Hot Battery Bus died (interestingly, not a scenario I'd ever seen in the simulator).  We got to the gate &amp; couldn't start the APU and couldn't connect ground power, so when we shut down both engines, we immediately had &quot;one blue light&quot; -- i.e. ground power is plugged in &amp; available, but NOTHING else -- dark airplane.
I don't recall how longer after that it was, but we eventually were able to connect ground power, probably to the ground service bus first.  Then, with the ground service bus powered, the battery would recharge.  I don't recall if we were able to get anything beyond the ground service bus powered after that.  (Presumably, if the battery recharged enough, we could have gone back to normal routines.)
As a practical matter, though, our maintenance does exactly as John K mentioned: if the battery has been depleted, it gets replaced.  How much of that is a matter of what happens during charging, and how much of that is concern about damage to the battery itself, I don't know, but in practice they won't use the aircraft's battery charger in the manner suggested in the OP.  (The battery charger brings it back up to full charge after things like starting the APU or running on battery power for the time between initial power-up and when APU or ground power are connected -- but that's a long way from being fully depleted.)