Was David's sin forgiven or not?
Yes. That has what to do with the question of indulgences or penance?
Because he still had to suffer the consequence of his sin to which you erroneously denied.
2 Samuel 12:13
13 David said to Nathan, "I have sinned against the LORD." And Nathan said to David, "The LORD also has put away your sin; you shall not die. 14 Nevertheless, because by this deed you have utterly scorned the LORD, * the child that is born to you shall die." 15 Then Nathan went to his house. And the LORD struck the child that Uriah's wife bore to David, and it became sick. ... 18 On the seventh day the child died. ...
This proves that even after sin is forgiven there's something left that remains (to which you denied). One of the purpose of indulgence is to get rid of this remains. Indulgence provided by the Church is the collective penance of the Saints the Church [Col 1:24], and more importantly, Christ. With this indulgence we do not have to do the arduous penance but lighter penance (10 Hail Marys).
And that ain't even the half of it. David's own son rebels against him and is killed in the civil war David's sin brought against Israel, eventually leading to the dividing of the kingdom.