Not long ago I read a book of Medieval ghost stories, going from the 700s to the 1400s. It's surprising how far back the ghost story tropes go, including the moaning and groaning, usually associated with a violent death.
The chain rattling goes back even further to ghost stories in Ancient Roman literature. Pliny the Younger wrote a haunted story, circa A.D. 102, with a chain rattling ghost. The ghost's corpse is found in chains. It was believed by the Romans that chains were one of the few ways to keep a ghost from wandering about. A 4th century author asserts,
Great, accordingly, are the chains on the ghosts; they tie even the most fleet and elusive apparition tightly to death and bind a soul like the body of a man accused.