The rigid body is characterized by a fixed point in it and a Cartesian coordinate system with the origin in this point fixed to the body (defining the "body frame"). Often it's convenient to choice the center of mass as this point. Let's denote ##\vec{s}## as the position vector of the fixed point with respect to a fixed inertial reference frame ("lab frame") and let ##\vec{x}## be the vector from the fixed point to an arbitrary other point in the body.
Let ##\vec{e}_j'## denote the body-fixed basis vectors. Then it's orientation to the lab frame is determined by a rotation matrix ##{D^i}_j## such that
$$\vec{e}_j'={D^i}_j \vec{e}_i,$$
where the ##\vec{e}_i## are the lab-fixed basis vectors. To get the kinematics described in convenient coordinates you can parametrize the rotation matrix by Euler angles, as described in any textbook of classical mechanics or also in Wikipedia. For the following that's not so important.
Now we determine the body's total kinetic energy. As we'll see, it's convenient to express the intrinsic motion in terms of body-fixed coordinates. So let the position vectors of the points defining the body be denoted by ##\vec{X}## (we have to sum (or integrate if you use the continuum description) over all these points). We have
$$\vec{X}=\vec{s}+\vec{x}=(\vec{s}^i+x^{\prime j} {D^i}_j) \vec{e}_i.$$
Here the ##\vec{e}_i## and the components ##x^{\prime j}## are time independent. Thus we have
$$\dot{X}^i=\dot{s}^i+x^{\prime j} {\dot{D}^i}_j. \qquad (*)$$
Now you have
$$\vec{x}=x^{\prime j} \vec{e}_j'={D^{i}}_j x^{\prime j} \vec{e}_i \; \Rightarrow \; x^i={D^{i}}_j x^{\prime j}.$$
Now let's switch to the matrix-vector notation. Let's denots with ##\boldsymbol{x}## the lab-fixed coordinates and with ##\boldsymbol{x}'## the boldy-fixed coordinates of ##\vec{x}##. Then the latter equation reads
$$\boldsymbol{x}=\hat{D} \boldsymbol{x}' \; \Rightarrow \; \boldsymbol{x}'=\hat{D}^T \boldsymbol{x}, \quad \hat{D}^T=\hat{D}^{-1}.$$
The latter holds true, because ##\hat{D}## is an SO(3) matrix. Now in our matrix-vector notation (*) reads
$$\dot{\boldsymbol{X}}=\dot{\boldsymbol{S}} + \dot{\hat{D}} \boldsymbol{x}'=\dot{\boldsymbol{S}} + \dot{\hat{D}} \hat{D}^{T} \boldsymbol{x}. \qquad (**)$$
Now because of ##\hat{D} \hat{D}^T=\hat{1}## we have
$$\frac{\mathrm{d}}{\mathrm{d} t} (\hat{D} \hat{D}^T)=0 \; \Rightarrow \dot{\hat{D}} \hat{D}^T=-\hat{D} \dot{\hat{D}}^T=- (\dot{\hat{D}} \hat{D}^T)^T.$$
This means that the matrix in the last equation in Eq. (**) is antisymmetric, i.e., we can as well write
$$\dot{\boldsymbol{X}}=\dot{\boldsymbol{S}} + \boldsymbol{\omega} \times \boldsymbol{x}.$$
The total kinetix energy thus is
$$T=\frac{1}{2} \sum_{\vec{x}} m_{\vec{x}} \dot{\boldsymbol{X}}^2=\frac{1}{2} \sum_{\vec{x}} m_{\vec{x}} [\boldsymbol{s}^2+2 \boldsymbol{s} \cdot (\boldsymbol{\omega} \times \boldsymbol{x}) + (\boldsymbol{\omega} \times \boldsymbol{x})^2].$$
If now ##\vec{s}## is the center of mass,
$$\vec{s}=\frac{1}{M} \sum_{\vec{x}} m_{\vec{x}} \vec{X} \; \Rightarrow \; \sum_{\vec{x}} m_{\vec{x}} \vec{x}=0.$$
So we have
$$T=\frac{M}{2} \dot{\boldsymbol{s}}^2 + \frac{1}{2} \sum_{\vec{x}} m_{\vec{x}} (\boldsymbol{\omega} \times \vec{x})^2.$$
Let's work out the last term in components:
$$\sum_{\vec{x}} m_{\vec{x}} (\boldsymbol{\omega} \times \vec{x})^2=\sum_{\vec{x}} \epsilon_{abc} \omega^b x^c \epsilon_{aij} \omega^i x^j =
\omega^b \omega^i \sum_{\vec{x}} (\delta_{bi} \delta_{cj}-\delta_{bj} \delta_{ci}) x^{c} x^j = \Theta_{bi} \omega^b \omega^i.$$
The tensor of inertia,
$$\Theta_{bi}=\sum_{\vec{x}} m_{\vec{x}} (\delta_{bi} \boldsymbol{x}^2-x_i x_j),$$
where I have used that in Cartesian coordinates ##x^j=x_j##,
can as well be expressed in terms of body-fixed coordinates, since
$$T_{\text{rot}}=\frac{1}{2} \boldsymbol{\omega}^T \hat{\Theta} \boldsymbol{\omega}=\frac{1}{2} \boldsymbol{\omega}^{\prime T} \hat{\Theta}' \boldsymbol{\omega}'.$$
Since ##\hat{\Theta}'## as a body-fixed quantity with respect to the body-fixed basis, it's time-independent, and we can always choose the body-fixed basis as the principal basis of this symmetric matrix. Then ##\hat{\Theta}'=\mathrm{diag}(\Theta_1',\Theta_2',\Theta_3').##
Now one can express the ##\boldsymbol{\omega}'## in terms of the Euler angles and its derivatives, and thus we have the kinetic energy as we need it in the Lagrange formalism in terms of the 6 degrees of freedom of the body, i.e., the three components ##s^j## of the center of mass of the body and the three Euler angles defining the rotation between the body-fixed Cartesian basis and the lab-fixed Cartesian basis.
$$L=\frac{M}{2} \dot{s}^2 + \frac{1}{2} [\Theta_1 (\omega^{\prime 1})^2+\Theta_2 \omega^{\prime 2})^2+\Theta_3 \omega^{\prime 1})^2].$$