Minimizing Time Sidelobes with Pulse Compression
You could define a weight sequence $w(n)$ that weighs the error differently for different time indices $n$:

$$\epsilon^2=\sum_{n=0}^{N+K-2} w(n)\big|d(n)-z(n)\big|^2\tag{1}$$

Samples that are too large get a higher weight, whereas samples that are smaller than necessary can get a lower weight.
Of course, you cannot know in advance which samples should get which weight, so you need to iteratively solve the RMS problem minimizing $(1)$, and adapt the weight sequence $w(n)$ in each iteration depending on the magnitude of the error $e(n)=d(n)-z(n)$.

A possible update rule for the weights $w(n)$ is

$$w^{(k)}(n)=\frac{\left|e^{(k)}(n)\right|}{\displaystyle\frac{1}{N+K-1}\sum_n\left|e^{(k)}(n)\right|}\cdot w^{(k-1)}(n)\tag{2}$$

where $k$ is the iteration index. You probably need to experiment a bit with the update equation to adapt it to your desired result, but the general idea is to increase the weight where the resulting error is too large and decrease it where it is smaller than needed.

This type of algorithm is called iteratively reweighted least squares.