Jennifer Jacquet argues that shame can be morally good as a tool the weak can use against the strong: The real power of shame is it can scale. It can work against entire countries and can be used by the weak against the strong. Guilt, on the other hand, because it operates entirely within individual psychology, doesn’t scale. […] We still care about individual rights and protection. Transgressions that have a clear impact on broader society – like environmental pollution – and transgressions for which there is no obvious formal route to punishment are, for instance, more amenable to its use. It should be reserved for bad behaviour that affects most or all of us. […] A good rule of thumb is to go after groups, but I don’t exempt individuals, especially not if they are politically powerful or sizeably impact society. But we must ask ourselves about the way those individuals are shamed and whether the punishment is proportional. Jennifer Jacquet: ‘The power of shame is that it can be used by the weak against the strong’
i would like to add that public shaming can also be related to consequentialism. The reason is that, for the person to be publicly shamed, they must have done something wrong. But sometimes being publicly shamed are done out of malice to make fun of someone, which is most directly tied to the ethics of egoism.