Yes that can be done.
But a couple or warnings-
Anything used for legal or regulatory purposes has to be calibrated & certified by an independent lab, and nobody is going to certify your homemade SPL meter.
It easy to calculate dB from an amplitude (as long as you have a reference). The reference the hard part so you'll need a real SPL meter (sound pressure level meter) to calibrate your "raw" ADC readings.
SPL is normally short-term averaged and [u]A-weighted[/u]. That's difficult in a "homemade" SPL meter. As long as you are always measuring the same thing (like a room full of people at a party) you can calibrate your meter to measure the same as the real meter. But when the nature of the sound changes, the readings will no longer match.
If you just want to set your own "annoyance level" without knowing the dB SPL, that's a whole lot easier. ;)
If you still want to proceed, here is a [u]previous post[/u] where I give an example of how to calibrate & calculate SPL.
Also, you need to realize that sound is a pressure wave. Even with a constant-tone the pressure is changing moment-to-moment. It's positive half the time and negative half the time, and it crosses-through zero twice per cycle. So, the readings will "look random" (within a range) and you'll have to find the peaks, or take an average of the positive values, or an average of the absolute values, or calculate the RMS, etc. Any of those methods can work because you'll be calibrating, and it's not going to be perfect anyway.
If that's confusing, the [u]Audacity website[/u] has a little explanation of how audio is digitized.