TL;DR: The sheriff did it to get rid of an sexually free woman in a small, conservative town and pin the crime on a man he wanted to get rid of.
The longer version:
I don't think Marx did although he had a plausible motive.
Marx character is shown to be a unreliable narrator and is also implied he discovered his mother's infidelity and burnt his house after his father left them when he was a child. It isn't clear if he told his father about the affair or if he found out by himself.
We can assume Marx had very complicated feelings about women and seeing Mary with another man could drive him to commit a crime as it was implyied he did when he was a kid.
The Sheriff seems very suspicious but I the only motive I think for him to murder Mary is to have a way to pin the crime on Marx to jail him or drive him out of town. People say the sheriff was jelous of Marx and Mary's relationship but aside from acting creepy towards Mary, he seems much more preocupied in destryoing Marx life.
It is stated that Marx was always unwanted on town and after his night on jail, the locals burn his trailer, forcing him to skip town. Thats why the sheriff felt so confortable murdering Mary, Marx was a social pariah and nobody would believe or defend him.
I also thing the sheriff didn't want Mary in town. She was kinda of a free spirit, associating with unwanted people in town and, from what is shown, very sexually confident and free, something that wouldn't be welcomed in a small, conservative, town like Harzard.
Murdering Mary and pinning it on Marx would kill to birds with one stone.