Corn snake

To scare off predators, they act as rattlesnakes.

An excerpt from the article 21 facts about corn snake
They hit their tail on the ground, creating a rattling sound.