A distant supernova is created by hostile aliens, as an attempt to wipe out humans.
The supernova happens to be at a distance where it would severely affect things on surface, however, it is far enough that assured destruction is not possible.
As far as I understand from other questions on the topic, it means the supernova should be somewhere between ~40 and 100 light years away.
Is it possible for the event to happen in such a manner or at such distance, that for humanity to dig itself some reasonable depth underground (let's say 1-2km) would make a difference between life and extinction(or significant risk thereof)?
And if yes, what would the supernova effect, against which 1-2km of rock helps, be on the surface?
It seems that the scenario you propose happens very often:
On average, a supernova explosion occurs within 10 parsecs (33 light-years) of the Earth every 240 million years.
So statistically it could have happened twice ever since life began. Further ahead in the article there is a section about past events:
Gamma ray bursts from "dangerously close" supernova explosions occur two or more times per billion years, and this has been proposed as the cause of the end Ordovician extinction, which resulted in the death of nearly 60% of the oceanic life on Earth.
What really called my attention, though, was this statement at the intro:
Historically, each near-Earth supernova explosion has been associated with a global warming of around 3–4 °C (5–7 °F).
We are having an increase in temperature like that on a century basis and it is destroying ecossystems. But in a flash? Immediate global death. The asteroid that killed dinosaurs didn't hit the whole surface of the Earth, but it did kill all dinosaurs in a matter of hours by cooking them alive when the global temperature rose a few degrees in under a day.
Back to novae, I'll spare you the math and just quote this:
It is estimated that a Type II supernova closer than eight parsecs (26 light-years) would destroy more than half of the Earth's ozone layer.
This would wreck havoc on us. Everybody going out as usual by day would get really bad sunburns. We would develop skin cancer within months to years. Many animals would also go extinct. Frogs are particularly susceptible to damage from UV. This could break every tropical ecosystem.
Gamma rays are responsible for most of the adverse effects a supernova can have on a living terrestrial planet. In Earth's case, gamma rays induce radiolysis of diatomic N2 and O2 in the upper atmosphere, converting molecular nitrogen and oxygen into nitrogen oxides, depleting the ozone layer enough to expose the surface to harmful solar and cosmic radiation (mainly ultra-violet). Phytoplankton and reef communities would be particularly affected, which could severely deplete the base of the marine food chain.
This would destroy farming worldwide as well. With global food production gone, living in an underground vault with a supply of food and viable seeds for reseeding the planet is the way to go.