Commenting on Paul's use of Psa 32 in Rom 4, Stanley E. Porter acknowledges that Paul is speaking of David himself as an example of a justification of a person, and that, in its original context, Psa 32 is also speaking of David's own justification:
In support of this opposition
between faith and works, Paul introduces his sub-exemplum of David. He
cites David as a support for the blessing of a person for whom God credits them
with righteousness apart from the law, and cites a passage from Ps 32.1-2 (Rom.
4.6-8). There are several features of this scriptural appeal to note. The first
is that, as opposed to Abraham, David lived during the time of the written
Jewish law (after its being given to Moses). As is noted further below (and as
Paul notes especially in Gal. 3.17, 19), the law is seen by Paul to have come
for a specific purpose, and Abraham preceded this giving and its purpose. But
David lived during the time when the written law was fully operative in its
regulative and sin-producing powers (see Rom. 5.20). However, when David cites
the passage from Psalm 32, one notes how he says how happy (blessed—a
beatitude; see Rom. 4.7, 8, 9) are those whose breakings of the law are
forgiven and whose sins are covered over, and how blessed is any person (‘man’)
for whom God does not reckon their sins against their account (Rom. 4.8). What
is not mentioned is the performance of any work to merit such blessing or
forgiveness. This is an example where a New Testament author invokes an entire
passage—here and entire Psalm—by simply citing the opening lines of the passage.
The entire psalm (Psalm 32) is given over to David’s praising God for his
forgiveness—none of it predicated upon ‘doing works’. Thus, David is invoked by
Paul as a support for what he is saying about righteousness apart from works,
and in support of his man example, Abraham, and as providing a line of
continuity through the entire Old Testament by means of another prominent
example. (Stanley E. Porter, The Letter to the Romans: A Linguistic and
Literary Commentary [New Testament Monographs 37; Sheffield: Sheffield
Phoenix Press, 2015], 104-5)
To understand the importance of this (i.e., David was re-justified in Psalm 32) see the discussion of Rom 4 at:
Response to a Recent Attempt to Defend Imputed Righteousness