As Francois Ziegler answered, the Bohr compactification is a compactification in the usual sense iff $G$ is compact. This is true with no restrictions.

By a "compactification in the usual sense" of a locally compact space $X$ I mean a continuous map $f:X\to Y$ where $f(X)$ is dense in $Y$ and $f:X\to f(X)$ is a homeomorphism. In that case $f(X)$ is necessarily open in $Y$ (this an easy exercise).

In case $X$ and $Y$ were groups and $f$ a group homomorphism, $f(X)$ was also closed, as any open subgroup is closed, thus $f(X)=Y$ by density. So $X$, being homeomorphic to $Y$, must have been compact to begin with.

More generally, let me note that any locally compact subgroup of any topological group is necessarily closed (and if the ambient group is locally compact, a subgroup is locally compact iff it is closed).