The Siegel variance formula for quadratic forms