Islamic State claimed responsibility for the killing of 39 people celebrating the New Year inside a fabled Istanbul nightclub, an act of terrorism that has become grimly familiar in Turkey as it fails to keep the violence in Syria from spilling into its cities.