Here is my attempt :
$\displaystyle F(x)=\int_0^x f(t)\;dt$ is a continuous and increasing function between $0$ and $\displaystyle I=\int_0^\infty f(t)dt$.
Suppose $\frac{F(x)}{x}$ is constant on $\mathbb R^+$ then there would exists some $a>0$ such that $F(x)=ax$.
But then $f(x)=F'(x)=a$ and $\displaystyle \int_0^\infty f(x)dx=+\infty$.
Thus there exists $(\alpha,\beta)\in\mathbb (R^{+*})^2$ such that
$\frac{F(\alpha)}{\alpha}\neq\frac{F(\beta)}{\beta}\tag{E}$
Assume $\alpha<\beta$ and let's define $g$ piecewise constant like below :
$\begin{cases}
\forall x\in[0,\alpha[, & g(x)=c \\
\forall x\in[\alpha,\beta[, & g(x)=-1 \\
\forall x\in[\beta,+\infty[, & g(x)=0
\end{cases}$
$\begin{array}{l}
0\ge\displaystyle \int_0^\infty f(x)g(x)dx=
\displaystyle \int_0^{\alpha}(c)f(x)dx+\int_{\alpha}^{\beta}(-1)f(x)dx+\int_{\beta}^{\infty} (0)f(x)dx \\
\iff cF(\alpha)-(F(\beta)-F(\alpha))+0\le 0
\end{array}$
But we also want $\displaystyle \int_0^\infty g(x)dx=c\alpha-(\beta-\alpha)>0$.
This is possible if $\quad\big(\frac{\beta-\alpha}{\alpha}\big)<c\le\big(\frac{F(\beta)-F(\alpha)}{F(\alpha)}\big)$
The double condition on $c$ requires that $\frac{F(\alpha)}{\alpha}<\frac{F(\beta)}{\beta}$
Instead we can reverse the intervals where $g$ is negative :
$\begin{cases}
\forall x\in[0,\alpha[, & g(x)=-c \\
\forall x\in[\alpha,\beta[, & g(x)=1 \\
\forall x\in[\beta,+\infty[, & g(x)=0
\end{cases}$
The condition on $c$ become $\quad\big(\frac{F(\beta)-F(\alpha)}{F(\alpha)}\big)\le c < \big(\frac{\beta-\alpha}{\alpha}\big)$
And if requires that $\frac{F(\alpha)}{\alpha}>\frac{F(\beta)}{\beta}$
But according to $(E)$ one of these two situations always happens, and the choice of a convenient $c$ is not an issue since $c=\frac{u+v}{2}$ always agrees the inequality $u<c<v$.
So we have succeeded in building a function $g$ that answers the question.