How do military fighter aircraft identify themselves and each other?
Military aircraft, like civil aircraft have transponders. Military aircraft  are assigned military codes, and their transponders have special military modes.

An aircraft doesn't need a transponder to be "illuminated" by radar, but the transponder enhances the "blip" and modern transponders transmit additional aircraft information such as altitude (Mode C). 

See the "Interrogation Modes" of transponders in this link.

Notice that the Military modes include "cryptographically" secured version of Mode S and ADS-B GPS positioning.