I will follow the techniques in http://www.math.uchicago.edu/~may/MISC/Dedekind.pdf
First, by localizing and using the fact that every finitely generated (fractional) ideal in $S^{-1}(A)$ is of the form $S^{-1} (I)$ for a finitely generated (fractional) ideal $I$ in A, we can reduce the problem to showing the following:
If $A$ is an integral domain (not a field), which is a local ring and every finitely generated fractional ideal is invertible, then $A$ is a valuation ring.
Let $x = a/b$. Consider the (fractional) ideal generated by $a$ and $b$, i.e., $(a,b)$. Proposition 1.6 tells you that $(a,b)$ is projective as $A$ module. Now since $A$ is local, this means $(a,b)$ is free. But of course, $b.a - a.b = 0$, so $(a,b)$ has rank $1$ as an $A$ module. Let $c := (a,b)$. Let $a = ct_1$ and $b = ct_2$. So $(t_1,t_2) = A$, i.e, either $t_1$ or $t_2$ is a unit. Since $x = a/b= t_1/t_2$, you can conclude that either $x$ or $x^{-1}$ is in $A$.
Comments: As you must have noted you can replace maximal ideal by prime in your original question. Also, I spent quite some time trying to do it by computation and failed. Can anyone point out a more explicit proof without localizing? (That is demonstrating $p$ and $q$ such that $aq = bp$ where one can actually say that either $p$ or $q$ is not in $\mathfrak m$.)