The basic rules for backshifting say how each verb should be backshifted. There's no exception in the rules for "when"-clauses.
Your sentence 2 follows those rules correctly, it has the meaning you intend, and it's 100% natural.
That said, there are times when we don't have to exactly follow those rules because the meaning stays the same and it still sounds natural. That might be what you're asking about here, about sentence 1, and the answer is no, in this case, sentence 1 would probably be understood correctly, but is grammatically incorrect.
I'm going to change your first sentence a bit to make it easier to follow the meaning of "there":
- He said he had been in traffic when I was in traffic.
This sentence means, "When I was in traffic, he said that he (too) had been in traffic (earlier)," which means he said that after he was out of the traffic, but while I was still in it.