George Mason University law professor Michael Krauss takes issue with the claim that Israel's economic sanctions on Gaza constitute collective punishment. He notes that, unlike the classic examples of collective punishment (Nazis massacring entire villages for resistance activities), Israel's alleged crime is merely that refuses to trade with its enemy. If Canada was lobbing missiles onto Buffalo, would we still have to send them cars from Detroit?
Close, but no cigar. While I certainly don't think Israel's actions rise to the level of Nazi barbarism, or close to it, my understanding is that Israel -- as an occupying power -- has special obligations towards Gaza compared to that of two unrelated belligerents. The closer analogy would be the US refusing to trade with Puerto Rico due to violent separatist activity in that state.
Electricity is a legitimate military target though, and as Krauss notes, Israel is merely restricting the flow of juice, not cutting it off, so that "Hamas will have to decide whether to provide electricity to hospitals or weapons lathes." That might be a legitimate move, except we all know Hamas' counter: give it to militants, then film sick kids outside of hospitals to showcase Israel's horrific cruelty. Who wins this battle? Usually not Israel.
In general, I don't think law or even morality is exhaustive of wisdom: one can make a legal or moral decision that isn't necessarily the best one. Israel has to ask itself whether the marginal (if present at all) boost in safety is actually getting them any closer to a long term solution to the conflict. I'm not convinced that it is.