The answer depends on the definition of collective punishment. Wikipedia here discusses the Fourth Geneva Convention and the definition of collective punishment:
Under the 1949 Geneva Conventions, collective punishment is a war crime. By collective punishment, the drafters of the Geneva Conventions had in mind the reprisal killings of World War I and World War II. In the First World War, the Germans executed Belgian villagers in mass retribution for resistance activity during the Rape of Belgium. In World War II, both the Germans and the Japanese carried out a form of collective punishment to suppress resistance. Entire villages or towns or districts were held responsible for any resistance activity that occurred at those places. The conventions, to counter this, reiterated the principle of individual responsibility. The International Committee of the Red Cross (ICRC) Commentary to the conventions states that parties to a conflict often would resort to “intimidatory measures to terrorize the population” in hopes of preventing hostile acts, but such practices “strike at guilty and innocent alike. They are opposed to all principles based on humanity and justice.”
Under this type of collective punishment, the innocent are punished with the guilty. The deliberate punishment of the innocent is intrinsically evil because the chosen act is inherently disordered. The act is directed toward a type of physical or moral violence against innocent persons.
But another feature of collective punishment, especially as used in wartime, is that the guilty are punished excessively. Every person who is guilty of something is innocent beyond the measure of his guilt. And so any deliberately excessive punishment is intrinsically evil, as it is a type of violence against the innocent.
If a type of collective punishment, let’s say not during wartime, is proportionate to the offense, then the punishment of the guilty, in that case, would not be intrinsically evil. But it would still be intrinsically evil to punish the innocent with the guilty.
And this remains true, even if the proportionate collective punishment has a good intended purpose, such as to encourage the group of persons to convince some of their members not to break a rule or a law. The end does not justify the means. Neither a good intention, nor a dire circumstance can ever justify any intrinsically evil act. Intention and circumstances never turn an intrinsically evil act into some other type of act, one that is moral.
On the other hand, if the chosen intervention is not a punishment directed at the innocent, but a reasonable measure directed at increasing safety and social order, such as a curfew, the act is not intrinsically evil. The suffering of the innocent, that their movements are restricted, is indirectly related to the chosen act; it is in the consequences and not also in the moral object.
The moral evaluation that collective punishment is intrinsically evil applies even if the punishment is mild, as when an entire classroom of children is punished for the misdeeds of a few children, or when a student body at a college is punished for the rule-breaking of a few students.
Suppose, in a different case, that one person breaks a rule, while three of his friends encouraged him to do so. All four persons are guilty. One is guilty of breaking the rule, and the others are guilty of encouraging him to break the rule. In such a case, when the entire group is guilty, in one way or another, the entire group can be given a proportionate punishment.
Please take a look at this list of my books and booklets, and see if any topic interests you.