You were on the right path. Possibly, you can do it way easier than I just did. However, this was how it came to mind for me. Note that I answered the question 'for higher $n$'. Perhaps it also works for $n \geq 3$, but I did not verify that. I'm sure that with more careful arguments (or simply bruteforce for $n=3$ and $n=4$) it should work.
Given a graph $G=(V,E)$ on $n$ vertices and $m$ edges, with $m = (n-1)(n-2)/2+1$. Suppose there is one pair of non-adjacent vertices $a$ and $b$ such that $d(a)+d(b) \leq n-1$ and that all other pairs are either adjacent or the sum of their degrees is at least $n$.
Find a set of pairs of distinct vertices $(u_1,v_1), ... ,(a_k,v_k)$ such that $(u_i,v_i)$ are non-adjacent and all pairs (including $(a,b)$) are pairwise disjoint e.g. each vertex is in at most one pair.
Then, the set of vertices $C$ in the graph that are in no pair, $C := V \setminus ( \cup_{1 \leq i \leq k} u_i \cup_{1 \leq i \leq k} v_i \cup \{a,b\} )$ induces a clique in $G$.
Let $H$ be a hamiltonian cycle in $G[V \setminus C]$. Let $w$ and $x$ be two adjacent vertices in $H$. Then, if there are two distinct vertices $y$ and $z$ in $C$ such that $wy \in E$ and $xz \in E$, there is an hamiltonian cycle for $G$. Therefore, if $w$ has one edge to $C$ and $x$ at least one, we are done. For a contradiction, assume that for all adjacent pair of vertices $w$ and $x$ in $H$, that either $x$ or $w$ has degree $0$ towards $C$. Then the total degree of this graph is at most*:
- Edges in $G[H]$ is at most $(n-|C|)(n-|C|-1)/2$
- Edges in $G[C]$ is $|C|(|C|-1)/2$
- Edges between $H$ and $C$ is at most $(|H|/2) \cdot |C| = ((n-|C|)/2) \cdot |C|$
However, we know that we have $m = (n-1)(n-2)/2+1 = (n-|C|+|C|-1)(n-|C|+|C|-2)/2 +1$ $ = (n-|C|)^2 + 2(n-|C|)|C|-3(n-|C|)-3|C|+|C|^2+2$ edges.
Comparing the quantities we find out that this is a contradiction. Therefore, it is sufficient to find a hamiltonian cycle in $G[V \setminus C]$ and we will focus on that from this point.
*The other case is both have degree $1$ towards $C$, but the total number of edges is lower, so it's the easier case.
Writing out the idea that you also wrote in your question:
Each vertex, apart from $a$ and $b$ has degree at most $n-2$, so therefore we have at most $((n-2)(n-2)+n-1) /2)$ edges in the graph.
- $(n-2)(n-2)+n-1 \geq 2m = (n-2)(n-1) + 4 $
- $n^2-4n+4+n-1 \geq 2m = n^2-3n+2 + 4 $
- $n^2-3n+3 \geq 2m = n^2-3n+6 $
Which is a contradiction, therefore for any two non-adjacent vertices the sum of their degrees is at least $n$.