Since the distance between two complex numbers a+i*b and c+i*d is (a-c)^2 + (b-d)^2, you could treat each complex number as a pair of independent real numbers. Wrap fun in a function rfun that returns the real and complex parts of the output. For example, assuming rfun returns a column vector,
function y = rfun(x)
y = rfun(x);
y = [real(y); imag(y)];
end
Similarly, you could replace ydata by
rdata = [real(ydata); imag(ydata)].
Then you have the first two inputs for lsqcurvefit.