This is accomplished by turning onto the downwind leg and climbing over a fixed spot (referenced by the moving map) that's within a relatively short radius (perhaps a half-mile or less) of the runway centerline. The chosen spot might even be halfway between the downwind and the runway centerline if there are obstacles on the side of the runway opposite the traffic pattern.
This climb technique has several advantages. First, it's unlikely you'll hit a mountain on your way up, because that's not how geography works. Second, you're protected by the fact that airports aren't typically sited where tall obstacles are within very close proximity.
Practically speaking, by the time you're on the downwind at midfield, a continued climb while turning toward the runway shouldn't expose you to typical pattern traffic. If there is traffic in the pattern, climb in the rectangular pattern until you're 500 feet above pattern altitude. Then resume your circling pivot over the chosen spot.