My ducks will wait by the backyard gate when they’re ready for bed and start walking to the coop when I go to get them, so I don’t really have to herd them necessarily, but they aren’t 100% on their own.
They are very good at learning routines though, I’m sure if I was dedicated enough and had an automatic door I could teach them to go in at the same time every night. I would probably add a “cue” first- like a bell ringing 5 minutes before the door closes. I would teach them by ringing the bell then encouraging them to go into the coop on their own and manually closing the door behind them, then I would gradually take myself out of the equation and let the bell and the door do all the work.