Theoretically an excavator could be designed which uses a winch-type system to curl the bucket (maybe a highly-geared transmission from an electric motor) and then, to uncurl it, lets gravity pull it and lets the spinning winch drive a generator. I can’t think of any way to do it that isn’t extremely inefficient though.
Plus as you say, excavators don’t use a winch and motor, they use hydraulics, and I don’t think the former would be powerful enough to move lots of earth. But OP said “theoretically”, which makes them technically correct (the best kind of correct.)
There are proposed energy storage systems that involve simply lifting a lot of heavy stuff to store energy, and then lowering it again to recover it. So the idea isn’t even new. But said systems have terrible energy density (lifting and lowering stuff doesn’t store very much energy overall) and are basically a terrible idea as it is.
Plus as you say, excavators don’t use a winch and motor, they use hydraulics, and I don’t think the former would be powerful enough to move lots of earth. But OP said “theoretically”, which makes them technically correct (the best kind of correct.)
There are proposed energy storage systems that involve simply lifting a lot of heavy stuff to store energy, and then lowering it again to recover it. So the idea isn’t even new. But said systems have terrible energy density (lifting and lowering stuff doesn’t store very much energy overall) and are basically a terrible idea as it is.