In this paper we provide an expansion formula for Hawkes processes which involves the addition of jumps at deterministic times to the Hawkes process in the spirit of the well-known integration by parts formula (or more precisely the Mecke formula) for Poisson functional. Our approach allows us to provide an expansion of the premium of a class of cyber insurance derivatives (such as reinsurance contracts including generalized Stop-Loss contracts) or risk management instruments (like Expected Shortfall) in terms of so-called shifted Hawkes processes. From the actuarial point of view, these processes can be seen as stressed scenarios. Our expansion formula for Hawkes processes enables us to provide lower and upper bounds on the premium (or the risk evaluation) of such cyber contracts and to quantify the surplus of premium compared to the standard modeling with a homogenous Poisson process.