First, we note that since
$$x_{n+1} =x_n - \frac{f(x_n)}{f'(x_n)} = 2x_2 - x_n^2y,$$
we have that
$$f'(x_n) = \frac{1}{x_n^2y-x_n}f(x_n).$$
Next, we note that if $f(x)$ has the form of an exponential function, i.e., $f(x) = \exp(u(x))$, we have
$$f'(x) = u'(x)\exp(u(x)) = u'(x)f(x).$$
Hence, we want some function $u(x)$, such that
$$u'(x) = \frac{1}{x^2y-x}.$$ Integrating both sides, we get $$u(x) = \log\left(\left|\frac{1}{x} - y\right|\right)+C.$$
Hence, our original function is $$f(x) = \exp\left(\log\left(\left|\frac{1}{x} - y\right|\right)+C\right) = e^c\left|\frac{1}{x} - y\right|.$$
We confirm this by considering $$x -\frac{f(x)}{f'(x)} = x - \frac{e^c\left|\frac{1}{x} - y\right|}{\frac{e^c(yx-1)}{\left|1/x-y\right|x^3}} = 2x-x^2y$$
EDIT
As Dr. Israel has pointed out in the comments, any function of the form
$$f(x) = a\left(\frac{1}{x}-y\right), \qquad a \ne 0$$ will work.