I've seen them done in a variety of ways. Many of ours were done with label makers, the kind that had the wheel and plastic tape that was sticky on one side. The tape came in a variety of colors including green.
Many times the letters will represent the Company or group to which they are issued. For example, my rack number at one time was B11. That would have been Company B, rack number 11.
Many were just painted on the stock in various locations including the upper part just behind the charging handle, the lower part just above the buttplate screw, or the lower left or right side just above the buttplate. The main reason they were painted on top of the stock was so that they could be seen while in the rack. That made it easy for the armorer to issue and recover the weapon.
Most of those that were painted used stencils. We had our own stencil making machine and used folders to punch out what we needed. I painted many vehicle windshields, duffel bags, and other equipment over the years with stencils I made on that machine.
One other method I saw recently, and it horrified me, was the use of dog tags that were riveted to the side of the stock! Fortunately these were on A2 stocks which are not collectible, yet.
I think I remember doing some with paint pens as well but those were a fairly recent invention.
Whatever you do, please stay away from the more destructive and more detracting methods such as electro pencils or stampings on the upper or lower receiver!