This is a follow-up to my question How many subgroups can there be in a group of order 512? Is it always 2 mod 4?, which in turn was inspired by the question What finite groups have as many elements as subgroups? of Richard Stanley. The suggestion in my question had counterexamples, found by Joachim König. This has caused me to reformulate the question as the following conjecture.
Conjecture. Let $G$ be a group of order $2^n$ with $n\geqslant 1$. Then the number of subgroups $s(G)$ is congruent to $-n-1$ modulo $4$ with the following exceptions. If $n$ is even and $G$ is cyclic, then $s(G)=n+1$. If $n$ is odd and $G$ is dihedral then $s(G)=2^n+n-1$. If $n$ is odd and $G$ is semidihedral then $s(G)=\frac{3}{4}.2^n+n-1$. If $n$ is odd and $G$ is generalised quaternion then $s(G)=\frac{1}{2}.2^n+n-1$.
For example, if $|G|=16$ and $G$ is non-cyclic then $s(G)$ is $3$ mod $4$. If $|G|=32$ and $G$ is not dihedral, semidihedral, or generalised quaternion, then $s(G)$ is $2$ mod $4$. If $|G|=64$ and $G$ is non-cyclic then $s(G)$ is $1$ mod $4$. And so on. For groups of order $512$, this would mean that $s(G)$ is $2$ mod $4$ except for three cases with $s(G)$ equal to $520$, $392$ and $264$ for dihedral, semidihedral, generalised quaternion respectively.
One consequence of this would be that for a group $G$ of order $2^n$ with $|G|=s(G)$, $n$ would have to be congruent to $3$ modulo $4$. This gives one tiny bit of information on the original question of Stanley.