How do I manipulate the sum of all natural numbers to make it converge to an arbitrary number?
The theorem itself is proven by giving the algorithm. You can find a proof on Wikipedia: https://en.wikipedia.org/wiki/Riemann_series_theorem
However, the sum of the positive integers doesn't converge, no matter what order you put them in. The -1/12 result comes from a broader notion of summation than convergence, and is not connected to the Riemann rearrangement theorem.
There is such an algorithm, but first a quick note: $\sum_{i=1}^\infty i$ is not a conditionally convergent sequence. It is not convergent at all. It is equal to $-1/12$ in the sense of Ramanujan convergence, but that is not applicable to the Riemann series theorem.
Suppose that the series $$\sum_{i=1}^\infty a_n$$ of real numbers is conditionally convergent. Then there must be an infinite subsequence $\{a_{n_k}\}$ of positive terms of $\{a_n\}$ and an infinite subsequence $\{a_{m_k}\}$ of negative terms of $\{a_n\}$. The sequence $\{a_{n_k}\}$ must ahve a largest element, and $\{a_{m_k}\}$ must have a smallest element. Let's say you want to rearrange the series to add to some number $r$. Suppose that $r>0$. Start adding the terms of $\{a_{n_k}\}$ starting from the largest on down until the sum is bigger than $r$. Then add terms of $\{a_{m_k}\}$ starting from the smallest on up until the sum is smaller than $r$. Then add some more terms of $\{a_{n_k}\}$ until the sum is bigger again, and continue the process forever. Since the series is conditionally convergent, both series $$\sum_{k=1}^\infty a_{n_k}$$ and $$\sum_{k=1}^\infty a_{m_k}$$ are infinite, so you can always complete each step. In the limit, your sum will be $r$. If you want to add to some $r<0$, do the same thing, but start with the negative terms instead.
The Riemann series theorem does not allow you to make the claim above because $ \sum_{n=1}^{\infty} n$ is not a conditionally convergent series.
Instead, an amazing but customary abuse of notation is used to write down this "identity". There is a function called the Riemann Zeta Function which is defined for every complex number except $s=1$. If $s$ has real part greater than $1$, the value of the Riemann zeta function equals $$ \zeta(s)=\sum_{n=1}^\infty \frac{1}{n^s}. $$ The Riemann zeta function also has $$ \zeta(-1)=\frac{-1}{12}. $$ Filling in $s=-1$, we get $$ \zeta(-1)``=''\sum_{n=1}^\infty n, $$ but this should not be taken too literally because the sum only converges when $s$ has real part greater than $1$ and does not hold if $s=-1$.