All things considered, the cost of extra barriers and policing, the draconian effects and questionable lawfulness of any sort of ban/fine, it seems to me the only solution that's plausible is for the route planners to take this problem into account when deciding the route. The forecast for major problems with the fans could have been forecast as soon as it was announced that the Zoncolan would be the final climb on the penultimate stage, of effectively the last race day, that was always bound to concentrate all the idiots in one place at the same time. Such hyperbolic race planning has got to influence the behaviour of these people, it's an invitation for trouble.
Put the same stage in the middle of the second week, would the same problems occur? It's perhaps notable these issues aren't so prevalent at the TdF, which is a bigger race, perhaps because traditionally it has the ITT before Paris instead of a insane mountain stage, both defusing the frenzy and allowing tighter control of the crowds.
Oh, what's more, let's face it, this year the Zoncolan was a non-event race-wise anyway, everything was already well wrapped up, Reason two for switching it around to an early point the next time the Giro goes up there.