Michael's answer is fantastic, but since someone might find this through specifically searching for loudness units, I thought it worth writing an additional answer more specific to the LUFS unit.
As Michael mentions in the end of his answer: $$\text{SPL} = 20\log_{10}\left(\frac{p_\text{rms}}{20~\mu\text{Pa}}\right)$$
The LUFS unit is very similar in concept, except as it's name (Loudness Units Relative to Full Scale) suggests, it is relative to the maximum amplitude the audio file can store.
Let's say in an audio file, sound pressure is stored in a value between $-1.0$ and $1.0$. Then a full scale wave is one that oscillates from one end of that range to the other (as opposed to between $-0.5$ and $0.5$, for instance).
This means that if we square any of these samples, we get a value between $0.0$ and $1.0$.
That then means "Relative to Full Scale" is essentially "Relative to $1.0$". So our $p_0$ becomes $1.0$ as opposed to SPL's $20μPa$. And since $\log_{10}(x)=\frac12\log_{10}(x^2)$, as Michael pointed out, we now have:
$$
20\log_{10}\left(\dfrac{p_{\text{rms}}}{1.0}\right) = 20\cdot\frac12\cdot \log_{10}\left({p_{\text{rms}}}^2\right) = 10\log_{10}\left({p_{\text{rms}}}^2\right)
$$
So then I think it becomes pretty clear, with $p_{\text{rms}} = \left(\sqrt{\text{avg}(p^2)}\right)$$p_{\text{rms}} = \sqrt{\text{avg}(p^2)}$, we get ${p_{\text{rms}}}^2 = \text{avg}(p^2)$ and therefore: $$10\log_{10}\left(\text{avg}(p^2)\right)$$ Which is what we see in the algorithm.
So essentially it's $dB_{SPL}$, but relative to the loudest-possible wave that can be held in a file, as opposed to the $20μPa$ reference that's normally used. This is also why the value is always negative, with people often mixing to a preferred max of $-8$ LUFS.
Some notes:
One other thing that is inherent to LUFS is the filters that come before the steps discussed. LUFS measurements start with two filters that approximately compensate for the loudness differences we perceive across different frequencies. See Equal-Loudness contour or Fletcher-Munson curves. That's why that $-0.691$ is present, because the second filter can actually amplify higher frequencies beyond $1.0$ and the subtraction brings it back down.
So it's not just that LUFS is a dB unit relative to the loudest possible sound that can be stored, it's also implicitly applied to the audio only after it's weighed across different frequencies to match the human perception of loudness.
Sound pressure is not stored in values between $-1.0$ and $1.0$.
Audio files will store samples in discrete "boxes" that may be 16-bit, 24-bit, 32-bit, etc.. Some of them may encode it differently for the sake of filesize (like mp3, aac, opus, etc..), but it will ultimately get decoded to that for reproduction.
In a 16-bit sample the sound pressure value is an integer that can vary from -32768 to +32767 (the full range split at the middle between positive and negative numbers, $2^{15}$ towards each side with $0$ counting as positive) - but for audio processing purposes, this range is thought of as "normalized" to [-1.0, 1.0].