The Hebrew text of 2 Sam. 12:31 uses the word וַיָּשֶׂם (vayyasem), which consists (in part) of a verb conjugated in binyan Paʿal (Kal) from the lemma שׂוּם (sum). In this binyan and particular context, the verb simply means “to put” or “to place.”
According to Gesenius,1
That is, David put the inhabitants of the city in saws, iron harrows, iron axes, and he caused them to pass במלכן.
There are three issues worthy of discussion in regards to your original question.
First, while 2 Sam. 12:31 uses the verb וַיָּשֶׂם (vayyasem), its parallel in 1 Chr. 20:3 uses the verb וַיָּשַׂר (vayyasar)—“and he sawed”—the difference being (excluding vowel pointing which did not exist in the earliest manuscripts) the final letter—ם versus ר. Of course, this could be the reason why some translations interpret 2 Sam. 12:31 as though David tortured the inhabitants of the city, as opposed to making them endure hard labor.2
In Rahlf’s edition of the Septuagint, 2 Sam. 12:31 has ἔθηκεν ἐν τῷ πρίονι (“he put [them] in a saw”), while 1 Chr. 20:3 has διέπρισεν πρίοσιν (“he sawed [them] through with saws”). Notably, a couple manuscripts of the Septuagint have διέπρισεν (“he sawed through”) in 2 Sam. 12:31 rather than ἔθηκεν (“he put”).3
Based on the parallel text of 1 Chr. 20:3, especially its translation in the Septuagint, one could reasonably conclude that David did indeed torture the inhabitants of the city after he conquered it.
Carl Friedrich Keil commented,4
He also had the inhabitants executed, and that with cruel tortures. “He sawed them in pieces with the saw and with iron harrows.” וַיָּשֶׂם בַּמְּגֵרָה, “he put them into the saw,” does not give any appropriate sense; and there can be no doubt, that instead of וישׂם we should read וַיָּשַׂר (from שׂוּר): “he cut (sawed) them in pieces.”
Second, in 2 Sam. 12:31 is the phrase “through the brickkiln.” Some Hebrew manuscripts have במלכן while others have במלבן, the difference being the second to last letter (Hebrew being read right-to-left), ב versus כ. Of course, like ד and ר, the difference between the shape of the graphemes is miniscule and a common cause of manuscript variance. The parallel verse in 1 Chr. 20:3 lacks either Hebrew word (and likewise the LXX of 1 Chr. 20:3). The LXX of 2 Sam. 12:31 has the Greek phrase διήγαγεν αὐτοὺς διὰ τοῦ πλινθείου—“and he drew (or “crossed/passed”) them through the brickwords” (or brickkiln).
Again, Carl Friedrich Keil,5
The meaning of the next clause is a disputed point, as the reading itself varies, and the Masoretes read בַּמַּלְבֵּן instead of the Chethibh במלכן, “he made them go through brick-kilns,” i.e., burnt them in brick-kilns, as the LXX. and Vulgate render it. On the other hand, Thenius takes the Chethibh under his protection, and adopts Kimchi’s explanation: “he led them through Malchan, i.e. through the place where the Ammonites burned their children in honour of their idol.” ...But this explanation cannot be even grammatically sustained,
Most importantly, Carl Friedrich Keil notes,6
At the same time, the words of the text do not affirm that all the inhabitants of Rabbah were put to death in this cruel manner. הָעָם אֲשֶׁר בָּהּ (without כֹּל) refers no doubt simply to the fighting men that were taken prisoners, or at the most to the male population of the acropolis of Rabbah, who probably consisted of fighting men only. In doing this, David merely retaliated upon the Ammonites the cruelties with which they had treated their foes; since according to Amos i. 13 they ripped up women who were with child, and according to 1 Sam. xi. 2 their king Nahash would only make peace with the inhabitants of Jabesh upon the condition that the right eye of every one of them should be put out. It is sufficiently evident from this, that the Ammonites had aimed at the most shameful extermination of the Israelites. “Thus did he unto all the cities of the Ammonites,” i.e. to all the fortified cities that resisted the Israelites.
Third, in 2 Sam. 12:30 is the word מַלְכָּם. Again, vowel pointing did not exist in the original manuscripts. Thus, it would have appeared simply as מלכם. This word could be interpreted as “their king”—מַלְכָּם—composed of the word מלך (“king”) with a 3rd person plural pronominal suffix (“their”). However, it could also be interpreted as “Milkom” (KJV: “Milcom”)—מִלְכֹּם—a proper noun (name) referring to the god of the Ammonites.7 The only difference is in the vowel points; the consonants are identical, hence the reason for the differing textual interpretations. The context seems to suggest that David simply took the crown off their king, after having conquered their army. However, the LXX of 2 Sam. 12:30 interprets the Hebrew by essentially doubling מלכם, producing the Greek text «καὶ ἔλαβεν τὸν στέφανον Μελχολ τοῦ βασιλέως αὐτῶν»—“and he took the crown of Melchol their king.” Coincidentally, this also occurs in the LXX of 1 Chr. 20:2 which contains essentially the same Greek phrase (“καὶ ἔλαβεν Δαυιδ τὸν στέφανον Μολχολ βασιλέως αὐτῶν”).
Field, Frederick. Origenis Hexaplorum. Vol. 1. Oxonii: E Typographeo Clarendoniano, 1875.
Gesenius, Heinrich Friedrich Wilhelm. Gesenius’s Hebrew and Chaldee Lexicon to the Old Testament Scriptures. Trans. Tregelles, Samuel Prideaux. London: Bagster, 1860.
Keil, Carl Friedrich. Commentary on the Old Testament. 1900. Reprint. Trans. Martin, James. Vol. 2. Grand Rapids: Eerdmans, 1986.
1 Gesenius, p. 786, שׂוּם, (1)
2 Although וַיָּשַׂר, from the lemma שׂוּר, is translated as “and he sawed,” it should be noted that the verb is a hapax legomenon, only occurring once in the OT corpus.
3 Field, p. 564. These manuscripts of the Septuagint are numbers 82 and 93.
4 p. 395
6 p. 396
7 cp. 1 Kings 11:5, 11:33; 2 Kings 23:13