From the Super Mario Wiki
Hammer Knights are large enemies in Mario Kart 8 and Mario Kart 8 Deluxe. They are statues possessed by Boos that inhabit Twisted Mansion. Two of them appear on the final leg of the track at the track's side, wielding giant hammers. They continuously swing down their hammers onto the track, blocking the way for racers and potentially flattening them and causing them to stop. The ground underneath their hammers is also partially destroyed and has a Coin. Their hammers can also block incoming items, such as Green Shells and Red Shells. After the hammer slams the ground, the Boos that are possessing them float out of the statues. Whenever a Hammer Knight is knocked by a Spiny Shell, Star, Bullet Bill or Super Horn, the Boo shouts in pain.