Transistor as a heater device and measured by LM35 temperature sensor?
You can use a transistor as a heater, however you would be better off to add at least one resistor to control the collector current. Given that, you might want to use the resistor itself as the heater and drive the BJT or MOSFET fully on to minimize the power dissipation in the switching device. 

Dale makes suitable chassis-mount wire-wound resistors, and you can find other suppliers with similar products. Photo from Digikey: 



If you still want to use the transistor for some reason, you can make the transistor into a current sink and connect the collector to a fixed voltage, so power dissipation is more-or-less fixed when 'on' Look elsewhere here for ideas on how to do that. The easiest way would be to drive the base to +5 and add a resistor in the emitter so you'd get a current of 4.3V/Re and a transistor power dissipation of P=(12V-4.3V)*4.3V/Re. That doesn't count the power dissipated by the emitter resistor. 

If you reduce the drop on the emitter resistor to something less, like say 100mV you can put more of the dissipation in the transistor, but that requires a more complex circuit (we'd probably use an op-amp). An intermediate solution would have 600mV drop in an emitter resistor and use a BJT to throttle current to the base or voltage to the gate of a power transistor.