How much of a link there might be with depression I cannot say; I suspect that the variety of reasons for such behaviour in nature is too wide for simple generalisations of such a type.
Part of the problem is that there are many forms of herd behaviour. Elephant herds for example generally are very stable and loss of a member is traumatic. Other than a herd being scattered by a disaster, if a member deserts the herd it would be because it had become too weak to keep up and the herd too pressured to wait. Possibly that might lead to some form of or analogy to depression. However, many other kinds of social aggregations are far more competitive or exclusive, such as male lions being forced out of their prides by younger, stronger, or more numeroud usurpers. No particular mental trigger is needed in their situation, unless you count: "These #$%^&s are to tough for us to handle; let's get out of here!" Or: "Those old incumbents are too tough for us, let's try to crash another harem."
Commonly any old survivor of say a herd of grazers will not survive long enough to leave the herd, because predators are alert for the first sign of weakness, but if they do, the line of though might most likely be the likes of: "I feel tired and lousy; staying with these guys is no longer any good. I'll go off for a rest."
Get the idea? Not that I pretend that my presentation is any more than a Just-So story, but to a prepared mind Just-So stories are valuable in themselves.