Identification of Ships

All registered ships have a device known as a 'ping transponder' which is 'tamper-proof' - a kind of electronic registration plate. Space traffic control and ship's nav-com can interrogate ('ping') the transponder and it comes back with current course, velocity, mass, port of origin, owner etc.
Military ships can turn their ping off, but civilian ships cannot. A ship not responding to a ping is always considered hostile until proven otherwise - and the absence of ping is a clue that it might be a military ship (or a badly maintained civilian ship). As to removing the transponder altogether - its illegal - in virtually all polities, non-ping ships are impounded and confiscated and the crew imprisoned or worse.
However, it is possible to build up a sort of sensor fingerprint of a ship, but these are not recorded and can vary with time - the spectrum of the ship's main engine burn is one of the most obvious indicators - these tend to be slightly different between military and civilian vessels - though identification is seldom certain.
Other indicators are the frequency range and efficiency of its navigation radar, the ships radar albedo etc - these tell something about who manufactured the ship, possibly.
Of course, successful pirates are able to 'tamper' with the ping transponder and set up fake ID for their ship - sometimes several (though it's expensive - they need to find a highly skilled but crooked electronics engineer - they don't come cheap).
However, even then fake ID is still risky - the ID has to be of a real registered ship - and there is a tiny but real chance of encountering the original owner of the ID at a port somewhere.