Cocolo means a black person that speaks english. It means black person in the same sense that
gringo or
yankee means white person. It can be a racial slur if the speaker wants it to be (just like gringo) but it is not a spanish word for nigger. It originally referred to blacks that came from english speaking Caribbean Islands and settled in spanish speaking islands.