I bet there is a field in the database 'hc_allowed' with the values '0' and '1'. If you pick up the item, put it in your stash, it is probably defaulted to '1'. This means HC characters can use it.
As soon as you put it up for sale, it changes to 'hc_allowed = '0'. Now you can forever only use it on SC characters.
In programming 0 = false and 1 (or non zero) = true.
Now in displaying the stats for the item, they can do something like...
value = (1==hc_allowed)?"Hard Core Allowed" : "Hard Core Disabled"
In other words, its a relatively simple system to accommodate.