Since you haven't specified that such a function needs to be continuous or well-behaved in any way, it's quite easy to describe one.
The integral $\int_0^1 \frac1x\,dx$ diverges, so there is an infinite amount of area to work with. Measure off the section of curve with area 1 starting at $x = 1$ and working toward $x = 0$. Then measure off the next section of curve with area 1/2 and negate the curve over that interval. Then measure off the next section of curve with area 1/3 and skip over it, measure off the next section of curve with area 1/4 and negate it, etc. The resulting function has the desired property—by construction, its integral from 0 to 1 is $1 - \frac12 + \frac13 - \frac14 +\ldots = \log(2)$ but the integral of its absolute value (which remains $\frac1x$) diverges.