Let $n = p_1 \cdot p_2 \dots p_k$ where $p_i$ are primes and $k \geq 1$. Then $d = 2^k$ and we claim that the answer is $2^{k-1}$.
It is clear that we can't choose two divisors $a,b$ of $n$ so that $ab = n$, so this means we can choose at most $\frac{d}{2} = 2^{k-1}$ divisors.
Now if we choose the divisors that have $p_1$ in them, then we have chosen exactly $2^{k-1}$ divisors and now we show the property holds:
Let $n = a \cdot t$, we then have $a^2 + ab - n = a(a + b - t)$. If we assume this to be a square, then each prime in $a$ has to divide $a+b-t$ since $a$ is squarefree. So we get $a \mid b - t$. But, $p_1$ divides both $a$ and $b$, but it doesn't divide $t$ since $n$ is squarefree, thus we reached a contradiction.