Not a 'real' answer, but it was too big for a comment.
I wrote and ran some Mathematica code:
In[1]:=FullSimplify[
Solve[{40*x1 + 296*x2 + 945*x3 + 2048*x4 + 4500*x5 + 8640*x6 ==
616103, 1 <= x1 <= x2 <= x3 <= x4 <= x5 <= x6 <= 1000}, {x1, x2,
x3, x4, x5, x6}, PositiveIntegers]]
Running the code gives:
Out[1]={{x1 -> 1, x2 -> 2, x3 -> 3, x4 -> 12, x5 -> 27, x6 -> 54}, {x1 -> 1,
x2 -> 2, x3 -> 7, x4 -> 12, x5 -> 30, x6 -> 52}, {x1 -> 1, x2 -> 2,
x3 -> 11, x4 -> 12, x5 -> 33, x6 -> 50}, {x1 -> 1, x2 -> 3, x3 -> 3,
x4 -> 5, x5 -> 9, x6 -> 65}, {x1 -> 1, x2 -> 5, x3 -> 7, x4 -> 36,
x5 -> 40, x6 -> 41}, {x1 -> 1, x2 -> 6, x3 -> 19, x4 -> 29,
x5 -> 31, x6 -> 46}, {x1 -> 1, x2 -> 6, x3 -> 23, x4 -> 29,
x5 -> 34, x6 -> 44}, {x1 -> 1, x2 -> 6, x3 -> 27, x4 -> 29,
x5 -> 37, x6 -> 42}, {x1 -> 1, x2 -> 8, x3 -> 11, x4 -> 15,
x5 -> 37, x6 -> 47}, {x1 -> 1, x2 -> 8, x3 -> 15, x4 -> 15,
x5 -> 40, x6 -> 45}, {x1 -> 1, x2 -> 12, x3 -> 15, x4 -> 32,
x5 -> 32, x6 -> 45}, {x1 -> 1, x2 -> 12, x3 -> 19, x4 -> 32,
x5 -> 35, x6 -> 43}, {x1 -> 1, x2 -> 12, x3 -> 23, x4 -> 32,
x5 -> 38, x6 -> 41}, {x1 -> 1, x2 -> 18, x3 -> 19, x4 -> 35,
x5 -> 39, x6 -> 40}, {x1 -> 1, x2 -> 25, x3 -> 27, x4 -> 31,
x5 -> 31, x6 -> 44}, {x1 -> 1, x2 -> 25, x3 -> 31, x4 -> 31,
x5 -> 34, x6 -> 42}, {x1 -> 1, x2 -> 31, x3 -> 31, x4 -> 34,
x5 -> 38, x6 -> 39}, {x1 -> 2, x2 -> 3, x3 -> 3, x4 -> 15, x5 -> 39,
x6 -> 47}, {x1 -> 2, x2 -> 3, x3 -> 7, x4 -> 15, x5 -> 42,
x6 -> 45}, {x1 -> 2, x2 -> 4, x3 -> 7, x4 -> 8, x5 -> 24,
x6 -> 56}, {x1 -> 2, x2 -> 7, x3 -> 7, x4 -> 32, x5 -> 34,
x6 -> 45}, {x1 -> 2, x2 -> 7, x3 -> 11, x4 -> 32, x5 -> 37,
x6 -> 43}, {x1 -> 2, x2 -> 7, x3 -> 15, x4 -> 32, x5 -> 40,
x6 -> 41}, {x1 -> 2, x2 -> 8, x3 -> 19, x4 -> 25, x5 -> 25,
x6 -> 50}, {x1 -> 2, x2 -> 8, x3 -> 23, x4 -> 25, x5 -> 28,
x6 -> 48}, {x1 -> 2, x2 -> 10, x3 -> 11, x4 -> 11, x5 -> 31,
x6 -> 51}, {x1 -> 2, x2 -> 14, x3 -> 19, x4 -> 28, x5 -> 29,
x6 -> 47}, {x1 -> 2, x2 -> 14, x3 -> 23, x4 -> 28, x5 -> 32,
x6 -> 45}, {x1 -> 2, x2 -> 14, x3 -> 27, x4 -> 28, x5 -> 35,
x6 -> 43}, {x1 -> 2, x2 -> 20, x3 -> 23, x4 -> 31, x5 -> 36,
x6 -> 42}, {x1 -> 2, x2 -> 20, x3 -> 27, x4 -> 31, x5 -> 39,
x6 -> 40}, {x1 -> 3, x2 -> 3, x3 -> 11, x4 -> 25, x5 -> 27,
x6 -> 50}, {x1 -> 3, x2 -> 3, x3 -> 15, x4 -> 25, x5 -> 30,
x6 -> 48}, {x1 -> 3, x2 -> 3, x3 -> 19, x4 -> 25, x5 -> 33,
x6 -> 46}, {x1 -> 3, x2 -> 3, x3 -> 23, x4 -> 25, x5 -> 36,
x6 -> 44}, {x1 -> 3, x2 -> 5, x3 -> 7, x4 -> 11, x5 -> 36,
x6 -> 49}, {x1 -> 3, x2 -> 5, x3 -> 11, x4 -> 11, x5 -> 39,
x6 -> 47}, {x1 -> 3, x2 -> 9, x3 -> 11, x4 -> 28, x5 -> 31,
x6 -> 47}, {x1 -> 3, x2 -> 9, x3 -> 15, x4 -> 28, x5 -> 34,
x6 -> 45}, {x1 -> 3, x2 -> 9, x3 -> 19, x4 -> 28, x5 -> 37,
x6 -> 43}, {x1 -> 3, x2 -> 9, x3 -> 23, x4 -> 28, x5 -> 40,
x6 -> 41}, {x1 -> 3, x2 -> 11, x3 -> 11, x4 -> 14, x5 -> 43,
x6 -> 44}, {x1 -> 3, x2 -> 15, x3 -> 15, x4 -> 31, x5 -> 38,
x6 -> 42}, {x1 -> 3, x2 -> 16, x3 -> 23, x4 -> 24, x5 -> 26,
x6 -> 49}, {x1 -> 3, x2 -> 22, x3 -> 23, x4 -> 27, x5 -> 30,
x6 -> 46}, {x1 -> 3, x2 -> 22, x3 -> 27, x4 -> 27, x5 -> 33,
x6 -> 44}, {x1 -> 4, x2 -> 4, x3 -> 7, x4 -> 28, x5 -> 36,
x6 -> 45}, {x1 -> 4, x2 -> 4, x3 -> 11, x4 -> 28, x5 -> 39,
x6 -> 43}, {x1 -> 4, x2 -> 5, x3 -> 11, x4 -> 21, x5 -> 21,
x6 -> 54}, {x1 -> 4, x2 -> 5, x3 -> 15, x4 -> 21, x5 -> 24,
x6 -> 52}, {x1 -> 4, x2 -> 5, x3 -> 19, x4 -> 21, x5 -> 27,
x6 -> 50}, {x1 -> 4, x2 -> 7, x3 -> 7, x4 -> 7, x5 -> 30,
x6 -> 53}, {x1 -> 4, x2 -> 11, x3 -> 11, x4 -> 24, x5 -> 25,
x6 -> 51}, {x1 -> 4, x2 -> 11, x3 -> 15, x4 -> 24, x5 -> 28,
x6 -> 49}, {x1 -> 4, x2 -> 11, x3 -> 19, x4 -> 24, x5 -> 31,
x6 -> 47}, {x1 -> 4, x2 -> 11, x3 -> 23, x4 -> 24, x5 -> 34,
x6 -> 45}, {x1 -> 4, x2 -> 17, x3 -> 19, x4 -> 27, x5 -> 35,
x6 -> 44}, {x1 -> 4, x2 -> 17, x3 -> 23, x4 -> 27, x5 -> 38,
x6 -> 42}, {x1 -> 5, x2 -> 6, x3 -> 7, x4 -> 24, x5 -> 30,
x6 -> 49}, {x1 -> 5, x2 -> 6, x3 -> 11, x4 -> 24, x5 -> 33,
x6 -> 47}, {x1 -> 5, x2 -> 6, x3 -> 15, x4 -> 24, x5 -> 36,
x6 -> 45}, {x1 -> 5, x2 -> 6, x3 -> 19, x4 -> 24, x5 -> 39,
x6 -> 43}, {x1 -> 5, x2 -> 7, x3 -> 15, x4 -> 17, x5 -> 18,
x6 -> 56}, {x1 -> 5, x2 -> 12, x3 -> 15, x4 -> 27, x5 -> 40,
x6 -> 42}, {x1 -> 5, x2 -> 13, x3 -> 15, x4 -> 20, x5 -> 22,
x6 -> 53}, {x1 -> 5, x2 -> 13, x3 -> 19, x4 -> 20, x5 -> 25,
x6 -> 51}, {x1 -> 5, x2 -> 19, x3 -> 19, x4 -> 23, x5 -> 29,
x6 -> 48}, {x1 -> 5, x2 -> 19, x3 -> 23, x4 -> 23, x5 -> 32,
x6 -> 46}, {x1 -> 6, x2 -> 7, x3 -> 7, x4 -> 27, x5 -> 42,
x6 -> 42}, {x1 -> 6, x2 -> 8, x3 -> 11, x4 -> 20, x5 -> 27,
x6 -> 51}, {x1 -> 6, x2 -> 8, x3 -> 15, x4 -> 20, x5 -> 30,
x6 -> 49}, {x1 -> 6, x2 -> 8, x3 -> 19, x4 -> 20, x5 -> 33,
x6 -> 47}, {x1 -> 6, x2 -> 12, x3 -> 35, x4 -> 37, x5 -> 37,
x6 -> 39}, {x1 -> 6, x2 -> 14, x3 -> 15, x4 -> 23, x5 -> 34,
x6 -> 46}, {x1 -> 6, x2 -> 14, x3 -> 19, x4 -> 23, x5 -> 37,
x6 -> 44}, {x1 -> 6, x2 -> 14, x3 -> 23, x4 -> 23, x5 -> 40,
x6 -> 42}, {x1 -> 6, x2 -> 15, x3 -> 15, x4 -> 16, x5 -> 16,
x6 -> 57}, {x1 -> 7, x2 -> 7, x3 -> 27, x4 -> 37, x5 -> 39,
x6 -> 39}, {x1 -> 7, x2 -> 9, x3 -> 11, x4 -> 23, x5 -> 39,
x6 -> 44}, {x1 -> 7, x2 -> 9, x3 -> 15, x4 -> 23, x5 -> 42,
x6 -> 42}, {x1 -> 7, x2 -> 10, x3 -> 11, x4 -> 16, x5 -> 21,
x6 -> 55}, {x1 -> 7, x2 -> 10, x3 -> 15, x4 -> 16, x5 -> 24,
x6 -> 53}, {x1 -> 7, x2 -> 16, x3 -> 19, x4 -> 19, x5 -> 31,
x6 -> 48}, {x1 -> 8, x2 -> 9, x3 -> 27, x4 -> 33, x5 -> 33,
x6 -> 43}, {x1 -> 8, x2 -> 9, x3 -> 31, x4 -> 33, x5 -> 36,
x6 -> 41}, {x1 -> 8, x2 -> 11, x3 -> 11, x4 -> 19, x5 -> 33,
x6 -> 48}, {x1 -> 8, x2 -> 11, x3 -> 15, x4 -> 19, x5 -> 36,
x6 -> 46}, {x1 -> 8, x2 -> 11, x3 -> 19, x4 -> 19, x5 -> 39,
x6 -> 44}, {x1 -> 8, x2 -> 15, x3 -> 27, x4 -> 36, x5 -> 37,
x6 -> 40}, {x1 -> 9, x2 -> 10, x3 -> 15, x4 -> 36, x5 -> 36,
x6 -> 42}, {x1 -> 9, x2 -> 10, x3 -> 19, x4 -> 36, x5 -> 39,
x6 -> 40}, {x1 -> 9, x2 -> 13, x3 -> 15, x4 -> 15, x5 -> 30,
x6 -> 50}, {x1 -> 9, x2 -> 17, x3 -> 31, x4 -> 32, x5 -> 34,
x6 -> 42}, {x1 -> 9, x2 -> 23, x3 -> 27, x4 -> 35, x5 -> 35,
x6 -> 41}, {x1 -> 9, x2 -> 23, x3 -> 31, x4 -> 35, x5 -> 38,
x6 -> 39}, {x1 -> 10, x2 -> 12, x3 -> 19, x4 -> 32, x5 -> 33,
x6 -> 44}, {x1 -> 10, x2 -> 12, x3 -> 23, x4 -> 32, x5 -> 36,
x6 -> 42}, {x1 -> 10, x2 -> 12, x3 -> 27, x4 -> 32, x5 -> 39,
x6 -> 40}, {x1 -> 10, x2 -> 14, x3 -> 15, x4 -> 18, x5 -> 42,
x6 -> 43}, {x1 -> 10, x2 -> 18, x3 -> 19, x4 -> 35, x5 -> 37,
x6 -> 41}, {x1 -> 10, x2 -> 25, x3 -> 31, x4 -> 31, x5 -> 32,
x6 -> 43}, {x1 -> 10, x2 -> 31, x3 -> 31, x4 -> 34, x5 -> 36,
x6 -> 40}, {x1 -> 11, x2 -> 14, x3 -> 23, x4 -> 28, x5 -> 30,
x6 -> 46}, {x1 -> 11, x2 -> 14, x3 -> 27, x4 -> 28, x5 -> 33,
x6 -> 44}, {x1 -> 11, x2 -> 20, x3 -> 23, x4 -> 31, x5 -> 34,
x6 -> 43}, {x1 -> 11, x2 -> 20, x3 -> 27, x4 -> 31, x5 -> 37,
x6 -> 41}, {x1 -> 12, x2 -> 15, x3 -> 15, x4 -> 31, x5 -> 36,
x6 -> 43}, {x1 -> 12, x2 -> 15, x3 -> 19, x4 -> 31, x5 -> 39,
x6 -> 41}, {x1 -> 12, x2 -> 16, x3 -> 23, x4 -> 24, x5 -> 24,
x6 -> 50}, {x1 -> 12, x2 -> 22, x3 -> 23, x4 -> 27, x5 -> 28,
x6 -> 47}, {x1 -> 12, x2 -> 22, x3 -> 27, x4 -> 27, x5 -> 31,
x6 -> 45}, {x1 -> 13, x2 -> 17, x3 -> 19, x4 -> 27, x5 -> 33,
x6 -> 45}, {x1 -> 13, x2 -> 17, x3 -> 23, x4 -> 27, x5 -> 36,
x6 -> 43}, {x1 -> 13, x2 -> 17, x3 -> 27, x4 -> 27, x5 -> 39,
x6 -> 41}, {x1 -> 13, x2 -> 23, x3 -> 23, x4 -> 30, x5 -> 40,
x6 -> 40}, {x1 -> 14, x2 -> 19, x3 -> 19, x4 -> 23, x5 -> 27,
x6 -> 49}, {x1 -> 14, x2 -> 19, x3 -> 23, x4 -> 23, x5 -> 30,
x6 -> 47}, {x1 -> 16, x2 -> 16, x3 -> 19, x4 -> 19, x5 -> 29,
x6 -> 49}, {x1 -> 17, x2 -> 17, x3 -> 19, x4 -> 22, x5 -> 41,
x6 -> 42}, {x1 -> 18, x2 -> 23, x3 -> 31, x4 -> 35, x5 -> 36,
x6 -> 40}, {x1 -> 19, x2 -> 31, x3 -> 31, x4 -> 34, x5 -> 34,
x6 -> 41}, {x1 -> 20, x2 -> 20, x3 -> 23, x4 -> 31, x5 -> 32,
x6 -> 44}, {x1 -> 20, x2 -> 20, x3 -> 27, x4 -> 31, x5 -> 35,
x6 -> 42}, {x1 -> 20, x2 -> 20, x3 -> 31, x4 -> 31, x5 -> 38,
x6 -> 40}, {x1 -> 20, x2 -> 26, x3 -> 27, x4 -> 34, x5 -> 39,
x6 -> 39}, {x1 -> 21, x2 -> 22, x3 -> 27, x4 -> 27, x5 -> 29,
x6 -> 46}, {x1 -> 22, x2 -> 23, x3 -> 23, x4 -> 30, x5 -> 38,
x6 -> 41}, {x1 -> 27, x2 -> 29, x3 -> 31, x4 -> 38, x5 -> 38,
x6 -> 38}}
If we, for example, want to extend the search to $10^6$ the number of solutions is given by:
In[2]:=Length[FullSimplify[
Solve[{40*x1 + 296*x2 + 945*x3 + 2048*x4 + 4500*x5 + 8640*x6 ==
616103, 1 <= x1 <= x2 <= x3 <= x4 <= x5 <= x6 <= 10^6}, {x1, x2,
x3, x4, x5, x6}, PositiveIntegers]]]
Out[2]=128
Best Answer
Since this is only about $p$-adics, an elementary argument that comes to mind would be as follows (unless I totally missed something).
If $p\equiv 1\pmod4$, then $-1=a^2$ for some $a\in\mathbf{Z}_p^*$. Therefore $x^2$ and $(ax)^2=-x^2$ are equivalent.
If $p\equiv -1\pmod4$, then $-1=a^2+b^2$ for some integers $a,b\in\mathbf{Z}_p^*$. In this case $x^2+y^2$ is equivalent to $$ (ax+by)^2+(bx-ay)^2=(a^2+b^2)(x^2+y^2)=-(x^2+y^2). $$ Two or four such equivalences convert your $f$ to $g$.
And let's not forget the prime $p=2$. Taking norms of the product of quaternions $$ (2+i+j+k)(x_1+x_2i+x_3j+x_4k) $$ tells us that $$ \begin{aligned} 7(x_1^2+x_2^2+x_3^2+x_4^2)&=(2x_1-x_2-x_3-x_4)^2+(x_1+2x_2-x_3+x_4)^2\\ &+(x_1+x_2+2x_3-x_4)^2+(x_1-x_2+x_3+2x_4)^2. \end{aligned} $$ Combining this with the fact that $\sqrt{-7}\in\mathbf{Q}_2$ allows you to turn the sum of four squares to its negative by an equivalence transformation.