What can I do when coats of paint won’t hide/cover the shadow left on a wall by wooden shelves
I use a shellac based primer for things such as this.  It  has better hiding ability then just paint or regular primer. 

Give it two or more coats and see if it hides the problem and then you can apply the final paint. 

If you still see a shadow after the shellac primer you could try a coat of bonding primer over the shellac primer.