Computation of cohomology of Lie conformal and Poisson vertex algebras