Functions where the sum of its partial derivatives is zero

Note that your equation is equivalent to $$ (1,1,1,\dots,1)\cdot\nabla f=0 $$ This means that $f$ is constant on lines parallel to $(1,1,1,\dots,1)$; these lines are the characteristics of the partial differential equation.

Thus, we can define $f$ freely on $x_n=0$ and then $$ f(x_1,x_2,x_3,\dots,x_n)=f(x_1-x_n,x_2-x_n,x_3-x_n,\dots,0) $$


Define $$y_i:=x_i-x_n$$ for every $i=1,2,\ldots,n-1$, and $$y_n:=x_n\,.$$ Then, we have $$x_i=y_{i}+y_n$$ for each $i=1,2,\ldots,n-1$, and $$x_n=y_n\,.$$ Observe that $$\frac{\partial}{\partial y_n}=\sum_{k=1}^n\,\left(\frac{\partial x_k}{\partial y_n}\right)\,\frac{\partial}{\partial x_k}=\sum_{k=1}^n\,\frac{\partial}{\partial x_k}\,.$$ Hence, the given partial differential equation is equivalent to $$\frac{\partial \phi}{\partial y_n}(y_1,y_2,\ldots,y_{n-1},y_n)=0\,,$$ where $$\phi(y_1,y_2,\ldots,y_{n-1},y_n):=f\left(y_1+y_n,y_2+y_n,\ldots,y_{n-1}+y_n,y_n\right)\,.$$ Consequently, $\phi(y_1,y_2,\ldots,y_{n-1},y_n)$ is a function of $y_1,y_2,\ldots,y_{n-1}$. In other words, there exists a smooth function $\Phi:\mathbb{R}^{n-1}\to \mathbb{R}$ such that $$f\left(x_1,x_2,\ldots,x_{n-1},x_n\right)=\Phi\left(x_1-x_n,x_2-x_n,\ldots,x_{n-1}-x_n\right)\,.$$ We can check that such $f$ satisfies the condition. Your nontrivial example for even $n$ arises from taking $$\Phi(t_1,t_2,\ldots,t_{n-1}):=\exp\left(\sum_{i=1}^{n-1}\,(-1)^{i+1}\,t_i\right)\,.$$

In general, let $\alpha_1,\alpha_2,\ldots,\alpha_n\in\mathbb{R}$ be arbitrary with $\alpha_n\neq 0$. Then, all differentiable functions $f:\mathbb{R}^n\to\mathbb{R}$ that satisfy the partial differential equation $$\sum_{i=1}^n\,\alpha_i\,\frac{\partial f}{\partial x_i}(x_1,x_2,\ldots,x_n)=0$$ for every $x_1,x_2,\ldots,x_n\in\mathbb{R}$ take the form $$f(x_1,x_2,\ldots,x_n)=\Phi\left(\alpha_n\,x_1-\alpha_1\,x_n,\alpha_n\,x_2-\alpha_2\,x_n,\ldots,\alpha_n\,x_{n-1}-\alpha_{n-1}\,x_n\right)\,,$$ where $\Phi:\mathbb{R}^{n-1}\to\mathbb{R}$ is a differentiable function.