For $n=4$, the bound in your attempt gives $e\ge 19$. We can improve this bound to $23$, which is tight, as conjectured by @Calvin Lin (His intuition is great)
Lemma 1. Any graph $G$ with chormatic number $\chi$ has $e(G)\ge
\binom{\chi}{2}+|G|-\chi$.
edges bound using chromatic number
I suggest that you can read the proof of the
lemma before reading the answer below. I do not use the lemma directly, but I got my idea from the proofs inside the link.
Let $G$ be a graph, with the minimum number of edges, on $8$ vertices and any subgraph induced by $4$ vertices has $\ge 4$ edges. For two disjoint subset $A,B$ of $V(G)$, let $e(A,B)$ denote the number of edges between $A,B$.
Lemma 2. If $G$ contains two disjoint independent sets of size $2$, say $A$ and $B$, then $e(A,B)=4$.
Lemma 3. The maximum independent set in $G$ has size $\le 2$. The chromatic number $\chi$ of $G$ is at least $\frac{n}{2}=4$.
Case 1. $\chi=4$. We have $e(G)\ge \binom{4}{2}4=24.$
Case 2. $\chi=5$. Let $A=\{1,2\},B=\{3,4\},C,\{7\},\{8\}$ be a $5$-coloring.
Then $e(A\cup B\cup C,\{7\})\ge 5$, since if $1$ and $3$ (it can not be $1$ and $2$ by lemma 3) are not adjacent to $7$, then $\{1,2,3,7\}$ induces $\le 3$ edges.
In addition, there is an edge between $7,8$, since $\chi\neq 4$. We have $$e(G)\ge e(A,B)+e(B,C)+e(C,A)+e(\{7\},\{8\})+2\times 5
\\ \ge 3\times 4+1+10=23.$$
Case 3. $\chi = 7$. Let $A=\{1,2\}$, $\{3\},...,\{8\}$ be a $7$-coloring, then we claim that $e(A,\{3,...,8\})\ge 11.$
If $e(A,\{3,...,8\})\le 10$, assume that $13\notin E(G)$. Then $14\in E(G)$ since $\chi = 7$, and for any $i\in \{4,...,8\}$, we have $e(A, \{i\})=2$, otherwise the subgraph induced by $\{1,2,3,i\}$ has $\le 3$ edges. So $e(A,\{3,...,8\})\ge e(A,\{3\})+\sum_{i=4}^8e(A,\{i\})=1+2\times5=11$, contridict to it $\le 10$
In addition, the graph induced by $\{3,...,8\}$ is a complete graph since $\chi=7$.
We have $e(G)\ge e(A,\{3,...,8\})+e(\{3,...,8\})\ge 11+\binom{6}{2}= 26$.
Case 4. $\chi=6$. In this case, Let $A=\{1,2\},B=\{3,4\},\{5\},\{6\},\{7\},\{8\}$ be its $6$-coloring. Then $e(A,B)\ge 4$ and $e(\{5,6,7,8\})=6$ (since they form a $4$-clique.)
Assume $1$ and $4$ are adjcaent to all vertices in $\{5,6,7,8\}$ (since otherwise we can get a $5$-coloring).
We claim that $e(\{2\},\{5,6,7,8\})\ge 3$. If $\le 2$, assume $5,6$ are not adjacent to $2$. Then $\{1,2,5,6\}$ induces $\le 3$ edges.
So $e(G)\ge 4+6 +4\times 2+3\times 2=24$
Here is a graph corredponding to case 2 and shows that the bound $23$ is tight.
