How to solve an ILP problem with conditions in an objective function?
Introduce integer variables $x^+_i,x^-_i,y_i$, where each $y_i$ is 0 or 1.  The intended meaning of $y_i$ is that $y_i=1$ means $x_i$ is positive, $y_i=0$ means $x_i$ is zero or negative; and that $x^+_i$ captures the positive part of $x_i$ and $x^-_i$ captures the negative part.  We'll enforce that intention by adding the following constraints:

$$\begin{gather*}
x_i = x^+_i + x^-_i\\
0 \le x^+_i \le U \cdot y_i\\
L \cdot (1-y_i) \le x^-_i \le 0\\
0 \le y_i \le 1
\end{gather*}$$

This ensures that the $x_i,y_i,x^+_i,x^-_i$ are consistent.  Finally, note that

$$x_i \cdot f(x_i) = a_i x^+_i + b_i x^-_i,$$

so the objective function can be expressed as

$$\sum_i a_i x^+_i + b_i x^-_i,$$

which is a linear function of the variables.  Now maximize this objective function subject to the constraints above and any other constraints you might have, by feeding it to any ILP solver.

See Express boolean logic operations in zero-one integer linear programming (ILP) for other tricks of the trade.