Chevron posted a loss for the second quarter as it reported $2.8 billion in impairments, surprising the Street.