Is there an energy cost associated with flipping the spin of an electron?
I will try to describe what happens when two hydrogen atoms approach each other from infinity. At infinite separation the hydrogen atoms don't feel their mutual presence and each atom has one electron localized in its atomic 1s orbital. In the absence of magnetic fields it will not matter whether the spins of the electrons are parallel or antiparallel and you will basically have an ensemble of systems with an equal amount of triplet (parallel spins, $S=1$) and singlet (antiparallel spins, $S=0$) states, since $E_{\uparrow \uparrow} = E_{\uparrow \downarrow}$. But when hydrogen atoms are brought closer together the situation changes: For one thing each atom has a magnetic moment associated with its electronic spin and there will be a dipolar interaction between those magnetic moments. However this dipolar interaction will be very weak (in the order of $10^{-4} \, \mathrm{eV}$ at close interatomic distance) and won't have much influence. Another factor that comes into the game is spin-orbit coupling. Yet again, since $\ce{H}$ is such a light element spin-orbit coupling will be very, very weak and so it can be ignored too. But the predominant factor to be taken into acount is the exchange energy (its effect is in the order of $0.1$ to $1 \, \mathrm{eV}$). Here you can find a very nice treatment of the exchange energy for the hydrogen molecule which comes to the conclusion that


  For the hydrogen molecule the exchange energy is negative [...] so the state when the resultant spin is $S=0$ has the lower energy than the state when $S=1$.


This source also provides the potential energy curves for the hydrogen singlet and triplet states.



These curves amount to the following electron configuration diagrams:



${}$



So, the situation for the approaching hydrogen atoms is like this: If both atoms start out with electrons of opposite spin (i.e. the system is in a singlet state) you have the common case that the hydrogen atoms will bond together thus lowering the total energy of the system. But if both atoms start out with parallel spins (i.e. the system is in a triplet state) the total energy will rise when they get closer to one another and the atoms will not bond together but keep their distance. This can be understood from the electron configuration diagram of the triplet hydrogen molecule: The antibonding $\sigma^{*}$ MO is more destabilized than the bonding $\sigma$ orbital is stabilized by the interaction (this is generally true for 2-orbital interactions) and the energy splitting becomes larger the closer the hydrogen atoms get. But because of the Pauli principle the two electrons of like spin in the system can't both occupy the $\sigma$ MO but one is forced to occupy the $\sigma^{*}$ MO and thus the system's total energy rises when the hydrogen atoms approach each other. And because there is virtually no spin-orbit coupling for hydrogen the total angular momentum (represented by $L$) and the total spin (represented by $S$) of the electrons are essentially conserved quantities and there is no mechanism to facilitate intersystem crossing, i.e. the process of changing from the triplet to the singlet state has such a low probability that it virtually doesn't happen. The situation changes of course if you add an external bias to the system, e.g. irradiation with high-energetic light. Then a triplet-singlet transition might be possible but as I read it that was not your question.

So, the way MO-diagrams are often pictured with electrons of like spin pairing up in a bonding MO does not reflect the "real" situation of two atoms approaching each other from an infinite distance. But it is not meant that way although it is often pictured as such.

Update

So, in summary I established that if you have two hydrogen atoms in free space without spin-orbit coupling and relativistic effects they are stuck with the spin state they initially start out with and can't change it during their time evolution, i.e. they have to stay either on the triplet or the singlet Born-Oppenheimer surface and no switching between those is allowed. But I want to delve a little deeper into the reasons for it. If the hydrogen atoms wanted to change from triplet to singlet state, the atoms would have to transfer $1 \hbar$ of spin angular momentum somewhere else in order to comply with the law of conservation of momentum. In the absence of any particles to collide with the only possible mechanism by which this can be achieved is to emit a photon whose energy is equal to the energy difference between the triplet and the singlet state, i.e. $\Delta E = \hbar \omega = E_{\uparrow \uparrow} - E_{\uparrow \downarrow}$, and which would "carry away" the $1 \hbar$ of spin. But in order to emit a photon there must be a coupling between the electrons and the electromagnetic field. The magnitude of this coupling or in other words the probability for a transition from an initial to a final state under the emission of a photon is described by the transition dipole moment

\begin{equation}
  \Theta_{\mathrm{i} \to \mathrm{f}} = \big\langle \Psi_{\mathrm{i}} \big| \sum_{n} q_{n} \mathbf{\hat{r}}_{n} \, \big| \Psi_{\mathrm{f}} \big\rangle
\end{equation}

where $q_{n}$ and $\mathbf{\hat{r}}_{n}$ are the charge and the position operator of the $n^{\mathrm{th}}$ particle in the system respectively, and the subscripts $\mathrm{i}$ and $\mathrm{f}$ signify the initial and final states of the transition. Under the conditions of the Born-Oppenheimer approximation the contribution of the nuclei to $\Theta_{\mathrm{i} \to \mathrm{f}}$ will be zero for the situation at hand, so that we only need to be concerned with the electrons in the system. If there is a sizable spin-orbit coupling then the spin degrees of freedom and the spatial degrees of freedom are coupled via the total angular momentum operator $\mathbf{\hat{J}} = \mathbf{\hat{L}} + \mathbf{\hat{S}}$ because

\begin{align}
  \mathbf{\hat{J}}{}^{2} = \mathbf{\hat{L}}{}^{2} + \mathbf{\hat{S}}{}^{2} + \mathbf{\hat{L}} \cdot \mathbf{\hat{S}}
\end{align}

and $\mathbf{\hat{L}} = \mathbf{\hat{r}} \times \mathbf{\hat{p}}$ where $\mathbf{\hat{p}}$ is the momentum operator. However, if there is no spin-orbit coupling then $\mathbf{\hat{L}} \cdot \mathbf{\hat{S}} = 0$ and $\mathbf{\hat{J}}{}^{2} = \mathbf{\hat{L}}{}^{2} + \mathbf{\hat{S}}{}^{2}$, i.e.
the spin degrees of freedom and the spatial degrees of freedom are decoupled. That means you can make a product ansatz for the wave function where you seperate the spin-dependent part $| \psi(S) \rangle$ and the spatial part $| \psi(\mathbf{r}) \rangle$ such that $| \Psi \rangle = | \psi(\mathbf{r}) \rangle | \psi(S) \rangle$. So, for the transition dipole moment you get

\begin{equation}
  \Theta_{\mathrm{i} \to \mathrm{f}} = \big\langle \psi_{\mathrm{i}} (\mathbf{r}) \big| \sum_{n} q_{n} \mathbf{\hat{r}}_{n} \, \big| \psi_{\mathrm{f}}(\mathbf{r}) \big\rangle \underbrace{\big\langle \psi_{\mathrm{i}} (S) \big| \psi_{\mathrm{f}}(S) \big\rangle}_{= \, 0} = 0
\end{equation}

where $\langle \psi_{\mathrm{i}} (S) | \psi_{\mathrm{f}}(S) \rangle = 0$ because the initial state would be the triplet state ($S =1$) and the final state would be the singlet state ($S=0$) and spin wave functions for different $S$ are orthogonal.
So, no spin-orbit coupling means that the probability for a transition from a triplet to a singlet state under the emission of a photon is zero.

In real atoms and molecules there is of course some spin-orbit coupling, so $\Theta_{\mathrm{i} \to \mathrm{f}}$ will be larger than zero. But the spin-orbit coupling in hydrogen is tiny and so $\Theta_{\mathrm{i} \to \mathrm{f}}$ will be tiny too and thus the probability of a triplet-singlet transition will be tiny as well and can be neglected for all practical purposes.