There is a general rule of thumb that you need one nest for every four or five hens but that’s pretty loose. It will work in pretty small flocks but if you have a lot of hens, you don’t need as many per hen. There is no specific number that is a law of nature saying you need a specific number of nests for a specific number of hens. It really is pretty flexible.
In general you’ll find that most of them lay in the same nest if you have a relatively small flock. I’ve had three hens crowd into one nest to lay together with a fourth pacing outside waiting her turn to get in. There were totally empty nests available in that same immediate area.
I like having a minimum of two nests just for flexibility, even if you have four hens or less but that is just me. I like having the flexibility if a hen goes broody or something else happens, but many people with four or five hens are happy with just one nest.
For 12 hens, I’d think that 3 nests will be plenty.
Hens should not sleep in the nests. They should sleep on the roosts. They poop a lot when they sleep. Poopy eggs are not very nice. They tend to sleep on the highest thing they can find, so the roosts need to be higher than the nest boxes.
You’ll find we do all kinds of different things with nests. There are several threads on this forum that show what we do for nests. I’ll give a link to one of them.
Nesting Boxes
https://www.backyardchickens.com/forum/viewtopic.php?id=41108
The only reason many are often lined up is that they are easier to build that way. The chickens really don’t care.