Yes, this is part of a set of standard tricks that can be used to linearize polynomial terms involving integer, and especially binary variables. There are lots of such transformations, and most good integer programming (and especially mixed integer nonlinear programming) texts summarize them.
The best way to understand the transformation is to take it on a case by case basis. First consider $\delta_i = 0$. The first set of inequalities guarantees in this case that $z_i = 0$ which is what we want, and all the other constraints are redundant. If $\delta_i = 1$, then the first set of inequalities simply enforces the bounds since $z_i = y_i$ in this case. Moreover, $1 - \delta_i = 0$ means that the last 2 constraints enforce $z_i = y_i$.
There might be other ways to transform the quadratic term. For instance you could use some Big M type models, but those are usually not desirable since they yield weak relaxations if you pick your Big M parameter wrong.
You can do away with some of the constraints if your objective function "pushes" your variables in the right direction.
$$
\begin{align}
x\ge 0 \implies y = 1\\
x< 0 \implies y = 0
\end{align}
$$
I assume your variable $y\in \{0,1\}$ because there is no another possibility. Let $M$ be a big positive number.
$$
\begin{align}
x \geq (y-1)M\\
x < yM\\
-M \leq x < M
\end{align}
$$
Using the intervals $[-M, 0), [0, M)$ this set of constraints guarantees the asked properties. OK, this is exactly what you do, but when $x=0$ the second constraint $0<yM$ then $y\neq 0$.
You can rewrite as follow ($\epsilon > 0$) :
$$
\begin{align}
x \geq (y-1)M\\
x + \epsilon \leq yM\\
-M \leq x < M
\end{align}
$$
Note that $x + \epsilon \leq yM$ and $\frac{x}{M}+\epsilon \leq y$ are the same thing. It is correct. Probably, you make a mistake in your code because when $(x,y)=(0,0)$ the second constraint becomes $\epsilon \leq 0$. It is false for all $\epsilon >0$.
UPDATE
I think you proof these constraints using the following idea. Let $M>0$ be a big number and $\epsilon>0$ a small number. Assume $-M \leq x \leq M-\epsilon$.
$$y=\left\lfloor\frac{x}{M}\right\rfloor+1$$
Note that $0 \leq x \leq M-\epsilon \implies y=1$ and $-M \leq x < 0 \implies \lfloor\frac{x}{M}\rfloor = -1 \implies y=0$
$$y-1=\left\lfloor\frac{x}{M}\right\rfloor$$
$$y-1\leq \frac{x}{M} < y $$
$$y-1\leq \frac{x}{M} \leq y -\frac{\epsilon}{M}$$
$$
\left\{\begin{align}
& x \geq (y-1)M\\
& x \leq yM -\epsilon
\end{align}\right.
$$
Best Answer
Your piecewise-linear function is concave and so cannot be linearized without introducing a binary variable. If it were instead convex, you could use linear programming.