Several representations exist for 3D transformations where gimbal lock is not an issue (e.g., quaternions, angle-axis, and matrices).
In general, Euler angles represent a mapping $\mathbb{R}^3 \rightarrow SO(3)$ where $SO(3)$ is the special orthogonal group:
$$ \textrm{SO}(3) := \bigr\{
\mathbf{R} \in \mathbb{R}^{3 \times 3}
: \mathbf{R}\mathbf{R}^T = \mathbf{1}, \det{\mathbf{R}} = +1 \bigr\}$$
The derivative of this mapping is not always full rank (i.e., the mapping is surjective), which is part of the reason we have gimbal lock.
Often, gimbal lock can be ignored if only the start and end values are important (e.g., after applying several rotations), but if interpolating (e.g., in computer graphics), gimbal lock is a problem. This answer has some figures related to this: https://math.stackexchange.com/a/2108278/372907
In some cases, you can pick the order of rotation to avoid gimbal lock. However, this is application dependent. For example, gimbal lock can be avoided if representing a fixed-wing aircraft due to the physical constraints.