Suppose that $A$ is a real, $n \times n$ symmetric matrix. Define the map $F: \mathbf{R}^n \to \mathbf{R}$ by $x \mapsto x^T A x$.
Question: For which matrices $A$ is the map $f = F|_{S^{n-1}}$ convex?
Let us give an interpretation for convexity in the sense of the question above.
Definition: Let $M$ be a Riemannian manifold. A map $f: M \to \mathbf{R}$ is convex, provided that for every geodesic $\gamma: [0, 1] \to M$, and every $t \in [0, 1]$, $$ f(\gamma(t)) \leq t f(\gamma(0)) + (1-t) f(\gamma(1)).$$
Let us make three remarks now.
- First, this definition implies that $f \circ \gamma$ is a convex map for all geodesics $\gamma$ (check this via restricting $\gamma$, yielding yet another geodesic).
Secondly, when $M = \mathbf{R}^n$ with the usual flat metric, this definition reduces to $$ f(x_t) \leq t f(x_0) + (1-t) f(x_1), \qquad \mbox{for every $x_0, x_1 \in \mathbf{R}^n$}, $$ where above $x_t:= tx_0 + (1-t)x_1$, $t\in [0, 1]$. In other words, the usual definition of convexity for maps $\mathbf{R}^n \to \mathbf{R}$.
Finally, if $S^{n-1}$ is replaced by $\mathbf{R}^n$ above, then the answer to the question is simply for $A$ nonnegative definite.
The notion of convexity you are using is unnatural for functions defined on compact (connected) Riemannian manifolds: With this definition every convex function is constant. Indeed, suppose that $f: M\to {\mathbb R}$ is a convex function on a compact connected Riemannian manifold. Then $f$ is necessarily convex and, hence, attains its maximum at some point $p$. But for every $q\in M$ there is a geodesic $c$ in $M$ containing $q$ and $p$ as its interior point. Thus, the convex function $f|c$ is nonconstant. But a nonconstant convex function on an interval cannot attain its maximum at an interior point. Hence, $f(p)=f(q)$ and, therefore, $f$ is constant. (A small modification of this proof works even if you assume that $f$ is convex only on all distance-minimizing geodesics.)
Applied in the setting of your question, you have the bilinear form $\langle x, y\rangle=x^TAy$ on ${\mathbb R}^n$. Either the corresponding quadratic form $q(x)=f(x)$ is identically zero (which implies that $A=0$), or after multiplying the matrix $A$ by a scalar, we get $q(x)=1$ for all $x\in S^{n-1}$. But a bilinear form is uniquely determined by its quadratic form: $$ \langle x, y\rangle= \frac{1}{2}(q(x+y) - q(x) -q(y)). $$ Hence, $\langle x, y\rangle$ equals the standard dot product. In other words, $A=I$.