Can I refuse to give a cop my name?

Yes.

 

But some states have “stop and identify” laws which require you to give your name.

 

The general rule is as follows: It is not a crime to give a false name to an officer during a “consensual field interview”: i.e. you are not under arrest. After an arrest it is a crime to give a false name.