A generalized skein relation for Khovanov homology and a categorification of the $\theta$-invariant