From @Wolfgang Bangerth's answer, there exists a mapping function $(x,y,z)=\Phi(\xi,\eta)$ which can be expressed as a function of the basis shape functions. Using a similar notation as @Wolfgang Bangerth, the reference or base triangle is defined as:
$$
\left\{(\xi,\eta)\in {\mathbb R}^2: 0\le \xi \le 1, 0\le \eta\le 1, \xi \le (1-\eta)\right\}
$$
The shape functions on the base triangle are:
$$
\Phi_1(\xi,\eta) = 1-\xi-\eta,\\
\Phi_2(\xi,\eta) = \xi,\\
\Phi_3(\xi,\eta) = \eta.
$$
Now, the mapping between the 3D triangle and the reference triangle can be written as:
$$
(x,y,z) = \sum_{i=1}^3 \Phi_i(\xi,\zeta) X_i
$$
where $X_i$ refers to the coordinate vector $(x_i,y_i,z_i)$ of point $P_i$.
Then, we can write
$$
N_i(\Phi(\xi,\zeta)) = \Phi_i(\xi,\zeta)
$$
Now, to find the inverse relation, we need to find the inverse mapping function $\Phi^{-1}$. The mapping can be written in matrix form as follows:
$$
(x,y,z)^T = X_1 + A (\xi,\eta)^T
$$
where $A$ is the following $3x2$ matriz:
$$
[X_2-X_1, X_3-X_1]
$$
As we cannot invert this matrix, it seems impossible to find the inverse mapping function. However, we know that the 3D triangle lies in a 3D plane, which means that one coordinate ($x$ for instance) of a point on the triangle can be written as a function of the 2 other coordinates ($y$ and $z$). Introducing those dependencies in the equations, you can write the mapping as:
$$
(\widetilde{x},\widetilde{y})^T = B (\xi,\eta)^T
$$
where $B$ is now a $2x2$ matriz and $(\widetilde{x},\widetilde{y})$ is obtained by removing the coordinate dependency (parametrizing the 3D triangle in a 2D-space for instance).
So, all of this is possible, if you really need this. However, in FEM analysis, you typically do not need an analytical expression of your shape functions on the 3D triangle. If you know the value of a shape function on the basis element, you automatically know it on the 3D triangle thanks to the mapping function, and that should suffice.
The derivative of the shape function on the 3D triangle is more tricky though:
$$
\nabla_{\overline{x}} N_i = \nabla_\overline{\xi} \Phi_i \frac{d\overline{\xi}}{d\overline{x}}
$$
where $\frac{d\overline{\xi}}{d\overline{x}}$ is a $2x3$ matrix and generally hard to find. You can find it though, considering all the above, and their are many ways to get what you need. I usually transform my 3D triangle to a 2D space, so that $\frac{d\overline{\xi}}{d\overline{x}}$ becomes a $2x2$ matrix and can be obtained easily by inverting $\frac{d\overline{x}}{d\overline{\xi}}$.
This is a possible procedure. Let's perform a change of base:
$$
\overline{e_x} = \frac{\overline{X_1X_2}}{\|\overline{X_1X_2}\|}\\
\overline{e_z} = \frac{\overline{X_1X_2} \times \overline{X_1X_3}}{\|\overline{X_1X_2}\| \|\overline{X_1X_3}\|}\\
\overline{e_y} = \overline{e_z} \times \overline{e_x}
$$
Then, projecting on the new basis, the coordinates of the triangle (taking $X_1$ at the origin) become:
$$
X_1 : ( 0, 0, 0) \\
X_2 : ( \overline{X_1X_2} . \overline{e_x}, 0, 0)\\
X_3 : ( \overline{X_1X_3}. \overline{e_x}, \overline{X_1X_3} . \overline{e_y}, 0 )
$$
which are coordinates in a 2D plane.