Turrettin (Theol. Elench. Quaest. IX., p. 678) says, "Imputation is either of something foreign to us, or of something properly our own. Sometimes that is imputed to us which is personally ours; in which sense God imputes to sinners their transgressions. Some times that is imputed which is without us, and not performed by ourselves; thus the righteousness of Christ is said to be imputed to us, and our sins are imputed to him, although he has neither sin in himself, nor we righteousness. Here we speak of the latter kind of imputation, not of the former, because we are treating of a sin committed by Adam, not by us." The ground of this imputation is the union between Adam and his posterity. This union is not a mysterious identity of person, but, 1. "Natural, as he is the father, and we are the children. 2. Political and forensic, as he was the representative head and chief of the whole human race. The foundation, therefore, of imputation is not only the natural connection which exists between us and Adam, since in that case all his sins might be imputed to us, but mainly the moral and federal, in virtue of which God entered into covenant with him as our head." Again, "We are constituted sinners in Adam in the same way in which we are constituted righteous in Christ."
Again, (Vol. II., p. 707,) to impute, he says, "is a forensic term, which is not to be understood physically of the infusion of righteousness, but judicially and relatively." Imputation does not alter the moral character; hence the same individual may, in different respects, be called both just and unjust: "For when reference is had to the inherent quality, he is called a sinner and ungodly; but when the external and forensic relation to Christ is regarded, he is pronounced just in Christ." "When God justifies us on account of the righteousness of Christ, his judgment is still according to truth; because he does not pronounce us just in ourselves subjectively, which would be false, but in another putatively and relatively."
(source, C. Hodge's Commentary on Romans - pp. 280-281)