Hilbert transform in the frequency domain
The discrete-time Fourier transform (DTFT) is always periodic. This is also the case for the frequency response of the discrete-time Hilbert transformer. For this reason, the ideal frequency response is not only zero at DC but also at Nyquist, which corresponds to index $2$ for a signal of length $4$. Consequently, the correct way to do what you're trying to do is:

x = [1,2,7,3];
X = fft(x);
hil = [0,-1i,0,1i];
Y = hil .* X;
y = ifft(Y);
y =

  0.5  -3  -0.5  3