There are many ways to do this. Here are three:
Option 1
Let $y_i$ be a binary that equals $1$ if and only if $x$ is in the $i^{th}$ interval ($i\in \{[0,1],[1,2],[2,3]\}$). The idea is then to express $x$ as a convex combination of the extreme points of the intervals. Therefore, we introduce variables $\lambda_0, \lambda_1,\lambda_2,\lambda_3 \in \mathbb{R}^+$ with which we will achieve this.
The objective function is
$$
f(0)\lambda_0+f(1)\lambda_1+f(2)\lambda_2+f(3)\lambda_3=\lambda_0+\lambda_2+1.5\lambda_3
$$
and the constraints are
\begin{align*}
&y_1+y_2+y_3 = 1\\
&x = 0\lambda_0+\lambda_1+2\lambda_2+3\lambda_3\\
&\lambda_0+\lambda_1+\lambda_2+\lambda_3=1\\
&y_1\le \lambda_0+\lambda_1\\
&y_2\le \lambda_1+\lambda_2\\
&y_3\le \lambda_2+\lambda_3\\
&y\in \{0,1\}\\
&\lambda\ge 0
\end{align*}
Option 2
Alternatively, you can write the objective function as
$$
f=(1-x_1)+(x_2)+(\frac{x_3}{2})
$$
with constraints
$$
x=x_1+x_2+x_3\\
x\le 3\\
y_1\le x_1 \le 1\\
y_2\le x_2 \le y_1\\
0 \le x_3 \le y_2\\
y_1,y_2\in \{0,1\}
$$
$y_1$ and $y_2$ are binaries that equal $1$ if and only if variables $x_1$ and $x_2$ reach their upper bound. This ensures that, for example, if $x=1.5$, the solver has to fix $x_1=1$ and $x_2=0.5$.
Option 3
Write the function as follows:
$$
f=(y_1-x_1)+(x_2)+(\frac{x_3}{2}+y_3)
$$
subject to
$$
x=(x_1)+(x_2+y_2)+(x_3+2y_2)\\
y_1+y_2+y_3=1\\
0\le x_1\le y_1\\
0\le x_2\le y_2\\
0\le x_3\le y_3\\
y_1,y_2,y_3\in \{0,1\}
$$
This time, binaries $y_i$ equal $1$ if and only if $x$ is in the $i^{th}$ interval ($i\in \{[0,1],[1,2],[2,3]\}$).
Adopting the convention
$$
\max_X f(X) \ \ \text{s. t.}\ \ g(X) \ge 0
$$
introducing slack variables to transform the inequalities into equations and calling
$$
f(x,y,z)=-(x^2+y^2+z^2)\\
g_1(x,y,z,s)=5-2x-y-s^2\\
g_2(x,y,z,s)=2-x-z-s^2\\
g_3(x,y,z,s)=x-1-s^2\\
g_4(x,y,z,s)=y-2-s^2\\
g_5(x,y,z,s)=z-s^2
$$
we have the lagrangian
$$
L(X,\lambda,S) = f(X)+\sum_k \lambda_k g_k(X,s_k)
$$
so the stationary points are given for the solutions to
$$
\nabla L = 0 = \left\{
\begin{array}{rcl}
-2 \lambda_1-\lambda_2+\lambda_3-2 x=0 \\
-\lambda_1+\lambda_4-2 y=0 \\
-\lambda_2+\lambda_5-2 z=0 \\
-2 \lambda_1 s_1=0 \\
-2 \lambda_2 s_2=0 \\
-2 \lambda_3 s_3=0 \\
-2 \lambda_4 s_4=0 \\
-2 \lambda_5 s_5=0 \\
5-2 x-y=s_1^2 \\
2-x-z=s_2^2 \\
x-1=s_3^2 \\
y-2=s_4^2 \\
z=s_5^2 \\
\end{array}
\right.
$$
Solving this system of equations we get at
$$
\left[
\begin{array}{cccccccccccccc}
f & x & y & z & \lambda_1 & \lambda_2 &\lambda_3 &\lambda_4&\lambda_5&s_1^2&s_2^2&s_3^2&s_4^2&s_5^2\\
-11 & 1 & 3 & 1 & -6 & -2 & -12 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\
-10 & 1 & 3 & 0 & -6 & 0 & -10 & 0 & 0 & 0 & 1 & 0 & 1 & 0 \\
-\frac{13}{2} & \frac{3}{2} & 2 & \frac{1}{2} & -1 & -1 & 0 & 3 & 0 & 0 & 0 & \frac{1}{2} & 0 & \frac{1}{2} \\
-\frac{25}{4} & \frac{3}{2} & 2 & 0 & -\frac{3}{2} & 0 & 0 & \frac{5}{2} & 0 & 0 & \frac{1}{2} & \frac{1}{2} & 0 & 0 \\
-6 & 1 & 2 & 1 & 0 & -2 & 0 & 4 & 0 & 1 & 0 & 0 & 0 & 1 \\
-5 & 1 & 2 & 0 & 0 & 0 & 2 & 4 & 0 & 1 & 1 & 0 & 0 & 0 \\
\\\end{array}
\right]
$$
Here the $s_k=0$ show the actuating restrictions at each solution.
The final qualification should be done using the KKT criteria. At each solution point $X_k^*$ we should have
$$
-\nabla f(X_k^*) = \sum_{j\in I_k}\mu_j \nabla g_j(X_k^*)
$$
where $I_k$ is the set of indices for the active restrictions at $X_k^*$, and $\mu_j\ge 0, j\in I_k$
Attached a plot showing the feasible region and in blue the stationary points.
NOTE
The solution for the previous equations associated to the stationary points is quite easy to find due to the binary option at $\lambda_k s_k = 0$ The solution point is at the bottom left. Black vectors are $-\nabla f(X^*)$ and red vectors are $\nabla g_j(X^*),\, j\in I_k$
Best Answer
Since $x_1$ is binary, $u_1=x_1^3$ is also binary: $$ u_1\in \{0,1\} $$
Since $x_2$ is binary, $x_3$ is integer and $1\le x_3\le 7$, $u_2=x_2x_3$ can take values among the set $\{0,2,3,4,5,6,7\}$. So you need to define new binary variables $y_i$ that equal $1$ if and only if $u_2$ takes value $i\in \{0,1,2,3,4,5,6,7\}$: $$ u_2=0y_0+y_1+2y_2+3y_3+4y_4+5y_5+6y_6+7y_7, $$ and you need to force $u_2$ to take exactly one of this values: $$ y_0+y_1+y_2+y_3+y_4+y_5+y_6+y_7=1\\ y_i\in \{0,1\}\quad \forall i=0,\cdots,7 $$
Since $x_3$ is integer and $1\le x_3\le 7$, $u_3=x_3^3$ can take values among the set $\{1^3,\cdots,7^3\}$. With the same logic: $$ u_3=z_1+\cdots+7^3z_7\\ z_1+\cdots+z_7=1\\ z_i\in \{0,1\}\quad \forall i=1,\cdots,7 $$