You can never be too careful when it comes to choosing friends.

Literal

Friend [object-を] choose [on the occasion of-にあたっては] how-much careful-even overdoing [topic-は] is-not.

~にあたって is a formal compound particle meaning 'on the occasion of, when about to.' It elevates the register compared to the simpler とき. Combined with は (にあたっては), it topicalizes the occasion, making it the frame for the advice that follows.