This post concerns the second mean value theorem for definite integrals.
The proof of this theorem is actually similar to the proof of the integration by parts formula for Riemann integrable functions.
First notice that since $w$ is monotone, its set of discontinuity points is countable and hence has measure zero. By Lebesgue's criterion $w$ is integrable, and so the integral $\int_a^b w(x) f(x)~dx$ is well-defined.
Let $F(x) = \int_a^x f(s)~dx$. The LHS can be written as \[ w(b) F(b) - w(a) F(a) - (w(b) - w(a)) F(c) \] and we will try to prove the existence of $c$ such that \[ w(b) F(b) - w(a) F(a) - \int_a^b w(x) f(x)~dx = (w(b) - w(a)) F(c). \] Since we know that $F$ is a continuous function, it suffices by the intermediate value theorem to prove that \[ [ w(b) - w(a)] \inf F([a,b]) \leq w(b) F(b) - w(a) F(a) - \int_a^b w(x) f(x) ~dx \leq [w(b) - w(a)] \sup F([a,b]). \]
Let $\mathcal{D}$ denote a division of $[a,b]$ into finitely many closed intervals; in other words, elements of $\mathcal{D}$ are closed subintervals of $[a,b]$ and there exists a way to list the elements so that $\sup I_i = \inf I_{i+1}$ for intervals $I_i$ and $I_{i+1}$ in $\mathcal{D}$.
We can write \[ w(b) F(b) - w(a) F(a) = \sum_{I\in \mathcal{D}} w(\sup I) F(\sup I) - w(\inf I) F(\inf I) = \sum_{I\in \mathcal{D}} [w(\sup I) - w(\inf I) ] F(\sup I) + w(\inf I) [ F(\sup I) - F(\inf I)] \] Since $w$ is increasing, we have $w(\sup I) - w(\inf I) > 0$. And therefore we clearly have that the first sum \[ [ w(b) - w(a)] \inf F([a,b]) \leq \sum_{I \in \mathcal{D}} [w (\sup I) - w(\inf I)] F(\sup I) \leq [ w(b) - w(a)] \sup F([a,b]).\] Thus it remains to prove that \[ \sum_{I\in \mathcal{D}} w(\inf I) [ F(\sup I) - F(\inf I)] - \int_a^b w(x) f(x)~dx \] can be made arbitrarily small. This sum can be rewritten as \[ \sum_{I \in \mathcal{D}} \int_I (w(\inf I) - w(x)) f(x)~dx. \] If $w$ were continuous, then by uniform continuity, for every $\epsilon > 0$, we can pick $\delta > 0$ so that if $\mathcal{D}$ is $\delta$-fine, then this sum can be bounded by $\epsilon \int_a^b |f(x)|~dx$, and the theorem follows.
For general increasing $w$, however, what we can do is use that $w$ is Riemann integrable. Let $M > \sup |f([a,b])|$. Let $X\subseteq [a,b]$ denote the finite set of points at which the oscillation of $w$ is greater than $\epsilon'$, for some $\epsilon'$ to be fixed. (This set is finite since by monotonicity, the total change $w(b) - w(a) \geq \sum \epsilon' |X|$.) Choose our $\mathcal{D}$ such that it is $\delta$ fine for $\delta < \frac{\epsilon}{2|X||b-a| M}$. Then we have \[ \Big|\sum_{I \in \mathcal{D}\land I\cap X\neq\emptyset} \int_I (w(\inf I) - w(x)) f(x)~dx\Big| \leq |X| \delta |b-a| M < \frac{\epsilon}{2}.\] Here we used that since $w$ is monotone, its oscillation on any interval is no more than $b-a$.
Next, $[a,b]\setminus X$ is compact. Therefore there exists $r:[a,b]\setminus X$ such that for every $x\in [a,b]\setminus X$, the oscillation of $w$ on $(x-2r(x), x+2r(x))$ is no more than $2\epsilon'$. The set $\{ (x - r(x), x + r(x)) : x\in [a,b]\setminus X\}$ forms an open cover, and hence has a finite subcover. Let the $r$ denote the minimum radius of the finite subcover.
Now if we make sure $\delta < r$, this means that any $I\in \mathcal{D}$ that does not intersect $X$ must be contained in $(x-2r(x), x+2r(x))$ for some $x$ indexing the finite subcover. And this implies that the oscillation of $w$ on $I$ is no more than $2\epsilon'$. So \[ \Big|\sum_{I \in \mathcal{D}\land I\cap X = \emptyset} \int_I (w(\inf I) - w(x)) f(x)~dx\Big| \leq 2 \epsilon' \int_a^b |f(x)|~dx. \] And thus if we had chosen \[ \epsilon' < \frac{1}{4\epsilon \int_a^b |f(x)| ~dx}. \] then this sum would also contribute no more than $\epsilon /2$.
Since $\epsilon$ is arbitrary, we have proven the theorem.
Notice that if $\int_a^b |f(x)| ~dx = 0$ then $f$ vanishes almost everywhere and the theorem holds trivially; so we can rule out this case when defining $\epsilon'$.