What's this part of the bike, and is it safe to alter it? The video shows someone installing a gps bike tracker, however there is not much room in the top of the head tube, so he hammers down what's already in there in order to make room for the tracker.

In this video, (starting at 1 minute 30 seconds) 
                
              

I wanted to make a custom gps tracker for my bike as I'm into electronics, but I have no idea what this 'hammering' does. What is this part he's altering? And is it safe to do so?
What he hammered down is the star nut.  It's a gription (yes I made that word up) device that serves as an anchor point in the steer tube to allow the top cap to properly compress the headset during a headset adjustment.  Old or damaged star nuts are often driven all the way through the steer tube to remove them (that's why your steer tube is open at the bottom).  They are generally only hammered in a short ways because being longer serves no purpose.  In this case, so long as that GPS unit is as stiff as a steel bolt and allows for proper compression during an adjustment, it should be fine.