First of all, David does not state that the guilt of Adam's sin was imputed to him. Instead, when we examine what is said we can understand that David was deeply troubled for his sins and wicked behavior and convicted of his guilt:
"For I acknowledge my transgressions: and my sin is ever before me. Against thee, thee only, have I sinned, and done this evil in thy sight: that thou mightest be justified when thou speakest, and be clear when thou judgest. Behold, I was shapen in iniquity; and in sin did my mother conceive me" (Ps.51:3-5).
Here we see that David was acknowledging total responsibly for his actions and he was not placing the blame upon Adam or anyone else. He expressed his repentance in an extreme manner, using figurative language to express the idea that he had been sinful ever since he could remember.
After all, not everything that is said in Pasams 51 can be understood literally. Let us look at what else is said in the same Psalm:
"Behold, I was shapen in iniquity; and in sin did my mother conceive me. Behold, thou desirest truth in the inward parts: and in the hidden part thou shalt make me to know wisdom. Purge me with hyssop, and I shall be clean: wash me, and I shall be whiter than snow. Make me to hear joy and gladness; that the bones which thou hast broken may rejoice" (Ps.51:5-8).
If all of these verses are to be taken literally then verse seven can be evidence that men are cleansed from their sins "with hyssop." Verse eight can also be taken in a literal sense to teach that broken bones rejoice!
If you want the truth from David's writings then consider what he wrote here and there is no reason to suppose what he wrote is not to be taken literally:
"For thou hast possessed my reins: thou hast covered me in my mother's womb. I will praise thee; for I am fearfully and wonderfully made: marvellous are thy works; and that my soul knoweth right well" (Ps.139:13-14).
Are we supposed to believe that a person is wonderfully made even though he is made spiritually dead? Of course not. This is what the Lord Jesus said about little children:
"Then people brought little children to Jesus for him to place his hands on them and pray for them. But the disciples rebuked them. Jesus said, 'Let the little children come to me, and do not hinder them, for the kingdom of heaven belongs to such as these'" (Mt.19:13-14).
Are we supposed to believe that these little children were dead spiritually but the Lord said that the kingdom of heaven belongs to them?