Mimicry in Animals
The adaptation you are describing is called mimicry. There are two main types involving resemblance to an unpleasant animal.
Batesian Mimicry
A harmless species evolves to resemble a dangerous or unpalatable species. This protects the mimic from predators who have learned to avoid the model species. A classic example is the viceroy butterfly mimicking the monarch butterfly.
Müllerian Mimicry
Two or more unpalatable species evolve to resemble each other. This benefits both species because predators learn to avoid them more quickly.
When an animal protects itself from predators by looking like another unpleasant animal, it is called mimicry, specifically Batesian mimicry when the mimic is harmless.