Integrating $\frac{1}{x}$ There is a general (mis)conception that
$$\int \frac{1}{x} \, \mathrm{d}x = \ln|x| + C \label{1} \tag{1}$$
However, taking the indefinite integral as the set of all functions whose derivative is $\frac{1}{x}$, the technically correct answer should be
$$\int \frac{1}{x} \, \mathrm{d}x = \begin{cases} 
 \ln(x) + C & \text{if $x > 0$} \\  
 \ln(-x) + D & \text{if $x < 0$}  
 \end{cases} \label{2} \tag{2}$$
See Your calculus prof lied to you (probably) for more details.

Is $\eqref{2}$ correct and is $\eqref{1}$ incorrect? Or are they both acceptable?

I suppose $\eqref{2}$ is more correct but it perhaps doesn’t have any additional value compared to $\eqref{1}$ as the definite integral will give the same result for both (as the integral diverges if we move from the negative to positive $x$-axis).

Is there any other example where failing to define a piecewise function (with separate constants) as an integral can have serious consequences?

 A: If your goal is just to calculate definite integrals, then indeed the correct formula (2) has no more use than the sloppy one (1), because you will never integrate across a vertical asymptote, so you will not use both formulae at the same time.
However remember that computing definite integrals is not the only point of integration. The indefinite integral asks "what functions have ... as their derivative". And then formula (1) is just not the full answer. It makes you believe that all antiderivatives of $y=1/x$ look like these:

But in reality, there are many more, and they are only visible in formula (2). Here are two of them:

So if "additional value" means that you understand how many different antiderivatives a function can have, here it is. Note this will be far more striking if you ever want to solve differential equations.
Finally, the same matter happens with any real function whose domain has more than one connected component, e.g. as soon as there are vertical asymptotes. For example, the correct indefinite integral of $f(x)=\frac{1}{(x-7)^3}$ is indeed
$\displaystyle \int \frac{1}{(x-7)^3} dx = \begin{cases} -\frac{1}{2}\dfrac{1}{(x-7)^2}+C \text{ if } x < 7 \\ -\frac{1}{2}\dfrac{1}{(x-7)^2}+D \text{ if } x > 7 \end{cases}$,
and for $\displaystyle \int \frac{dx}{(x-7)(2x+1)(3x-4)(x+12)}$ you will "technically" need five independent constants on the five connected components of its domain.
A: Whenever you see a formula in the form of
$$
\int f(x)\;dx = F(x)+C\;\tag{*}
$$ there is implicitly some open interval $I$ that is the subset of the "natural domain" of the function $f$. The formula is interpreted as
all the solutions to the differential equation
$$
F'(x)=f(x),\quad\quad x\in I\;.\tag{**}
$$
In this context, the important property of open intervals is that they are connected, and that's why one has only one "arbitrary constant $C$".
In the case when $f(x)=\frac1x$, the natural domain  $D=\mathbf{R}\setminus\{0\}$ is not connected. Then ($*$) is true for any given open interval $I\subset D$.
However, if one wishes to express the solution set to the differential equation
$$
F'(x)=\frac1x,\quad x\in D=\mathbf{R}\setminus\{0\}\;,
$$
one needs two arbitrary constants, basically because there are two connected components of the domain $D$. That is what you write in (2) of your post.

So when one has a piecewise-defined function $f:D\to\mathbf{R}$ where the domain $D$ is not connected and if one wants to use $\int f(x)\; dx$ to express the set of all the solutions to the differential equation
$$
F'(x) = f(x)\quad x\in D\;,
$$
then one needs more than one "arbitrary constant", depending on the number of connected components of $D$. For instance, let $D=(0,1)\cup (2,3)\cup(4,5)$ and define $f:D\to\mathbf{R}$ with $f(x)=0$ for every $x\in D$. Then the solution set to
$$
F'(x)=f(x)\;,\quad x\in D
$$
is
$$
F(x)=\begin{cases}
C_1\;,&x\in(0,1)\\
C_2\;,&x\in(2,3)\\
C_3\;,&x\in(4,5)
\end{cases}\;.
$$
Another more frequently seen example in calculus exercises is the following. Suppose after performing partial fraction decomposition one has
$$
f(x)=\frac{1}{x}+\frac{1}{x-1}\;.
$$
Note that the natural domain for $f$ is $D=\mathbf{R}\setminus\{0,1\}$, which has three connected components.
One usually write
$$
\int \frac{1}{x}+\frac{1}{x-1}\;dx = \ln|x|+\ln|x-1|+C
$$
which is again, understood as solutions to ($**$) where $I$ is some connected subset of $D$.
A: This is the case for any function where the domain is not connected.  For example:
$$\begin{align}
f:\Bbb R\!\setminus\!\{0\} &\to \Bbb R \\
x&\mapsto 1
\end{align}$$
we also have
$$\int f(x)\,dx = \begin{cases}
x+C,& x < 0 \\
x+D,& x > 0 \\
\end{cases}$$
Yet, I would still prefer the notation
$$\int f(x)\,dx = x+C$$
for brevity; bearing in mind that this only holds for each connected component of the domain individually.

Reply to comment:
$|x|+C,D$ is not a good notation and confusing. And gets even more cumbersome if there are more (infinitely many) connected components like in $f:\Bbb R\!\setminus\!\Bbb Z\to\Bbb R$.
That $|x|$ is defined piecewise is not an issue here because usually, its domain is all of $\Bbb R$. For example, if we take
$$\begin{align}
g:\Bbb R\!\setminus\!\{1\} &\to \Bbb R \\
x&\mapsto |x|
\end{align}$$
then the trouble when integrating $g$ is at $x=1$, not at $x=0$.  Even if $g$ had a jump at $x=0$ would be no issue.
In the case of $g$, the integral could be written as
$$\int g(x)\,dx = \begin{cases}
|x|\cdot\operatorname{sign} x + C,& x < 1 \\
|x|\cdot\operatorname{sign} x + D,& x > 1 \\
\end{cases}$$
Yes, one could simplify that in the case $x>1$ because the signum is always 1 and $x=|x|$.  But writing $\int g(x)\,dx = 
|x|\operatorname{sign} x + C$ is still easier to grasp.
Then there is a question for why to add "+ C" after each and every indefinite integral; it's clear that you get a set of functions that, when derived, give the integrand.
A: 
$$\int \frac{1}{x} \, \mathrm{d}x = \ln|x| + C \tag{1}$$
$$\int \frac{1}{x} \, \mathrm{d}x = \begin{cases}   \ln(x) + C & \text{if $x > 0$} \\    \ln(-x) + D & \text{if $x < 0$}    \end{cases}\tag{2}$$
I suppose $(2)$ is more correct but it perhaps doesn’t have
any additional value compared to $(1)$ as the definite integral
will give the same result for both

The main value of presentation $(2)$ over presentation $(1)$ is paedagogical: it explicitly reminds us that $\displaystyle\frac1x$ has a break at $0$ (and to be cautious about attempting to integrate it on, say, $[0,5]$—notwithstanding the fact that $\displaystyle∫_0^5\frac{\mathrm dx}{\sqrt x}$ does converge).
It's a nice bonus that presentation $(2)$ exhibits the requisite independent parameters $C$ and $D$ (as opposed to the sole parameter in the indefinite integral of $|x|;$ see How many arbitrary constants to put in these integrals?), however this may just be of technical interest.
A: You are correct that the general form of an antiderivative of $\frac1x$ on $\Bbb R\setminus\{0\}$ will have two constants, one of either side of the origin. (If you want to be strict about it, it is most proper that the two constants differ by $i\pi$, for complex analysis reasons.)
For definite integrals, you can't really cross $0$ in any conventional way. So it doesn't matter whether you have a single constant or two. So for simplicity we only use one.
Indefinite integrals are either thought of as antiderivatives or as definite integrals with unknown and implied boundaries. Depending on which one indefinite integrals mean to you, that will dictate whether you should have one constant or two.
A: Use the notion of pseudo-constants, differentiable functions whose derivative is zero on their domain.  My replies to comments on the video at https://youtu.be/u4kex7hDC2o give definitions and results and examples, based upon published work with Charatonik (r.i.p.) on absolute differentiation in metric spaces and unpublished work with him on differentiation in topological fields.  In this special case, formulas (1) and (2) are unified in a formula that replaces C with a component-wise constant function and while I think that you're probably deluding yourself about your understanding if you use the  term "arbitrary", feel free to call it "an arbitrary pseudo-constant".
