Firstly, note that the minimization over $\gamma$ is a convex optimization problem. If we set the derivative inside to zero, we get the candidate solution $\gamma^* = \lambda - \frac{\left\lvert\theta\right\rvert}{a}$; this will be the solution if it is greater than zero (which requires $\left\lvert \theta \right\rvert \leq \lambda a$), otherwise, we will have $\gamma^* = 0$.
You can plug this into the expression for $f(\theta)$ to obtain
$$
f(\theta) =
\begin{cases}
\frac{1}{2}(\theta - z)^2 + \frac{a\lambda^2}{2}, \:\: \text{if } \left\lvert \theta \right\rvert > \lambda a\\
\frac{1}{2}(\theta - z)^2 + \lambda \left\lvert \theta \right\rvert - \frac{\theta^2}{2a}, \:\: \text{if } \left\lvert \theta \right\rvert \leq \lambda a
\end{cases}
$$
Note that both pieces are convex since $a > 1$. To find the optimal solution $\hat{\theta}$, you find the optimal solution of each piece separately, and compare them to see which one is better.
For the first piece above, the optimal solution is $z$ if $\left\lvert z \right\rvert \geq \lambda a$, the optimal solution is $+\lambda a$ if $0 < z < \lambda a$, and the optimal solution is $-\lambda a$ if $0 > z > -\lambda a$, and the optimal solution is $\pm \lambda a$ if $z = 0$. I determined these by setting the derivative to zero, or looking at a boundary point.
For the second piece above, the optimal solution is $\frac{a}{a-1} (z-\lambda)$ if $\lambda \leq z \leq \lambda a$ and the optimal solution is $\frac{a}{a-1} (z+\lambda)$ if $-\lambda \geq z \geq -\lambda a$.
Can you take it from here?