TL;DR: Everybody's telling me the solution to my problems is X, only X isn't in the game. So what kind of crappy solution is that?!
One of the ones that'd actually work...
Now, here comes the elephant(s) in the room, that nobody seems to actually want to discuss:
* The official published scenarios never* provide what's needed to enforce this attrition.
* The rules never enforce any attrition.
So 5e's big schtick is "DM Empowerment," that means the DM is given the tools (sorta) and the latitude (parsecs of it), to make the game into what he wants. It also means he has to work at it a bit...
How do you make attrition work in a game where you don't fancy doing all the hard work, and instead rely on official published supplements?
If you don't fancy doing the hard work, don't DM, play. Seriously. Problem solved. If you aren't up to the challenge of running 5e, don't run it. We /need/ DMs, sure, but DMs who are going to do a good job of DMing.
How many encounters and short rests do you have per long rest?
Whatever feels right for the pacing of the adventure. Yeah, there's a guideline, and yeah, it works in theory. But I'd rather not wrap my campaign in knots to follow it, I'll adjust intraparty and encounter balance in other ways - by emphasizing certain challenges to move that metaphorical spotlight around, for instance.
What does the party need to do when they feel they need to stop and rest?
Stop, rest, and remain undisturbed for the requisite period of time.
What's stopping them from doing this?
The world (ie the DM, with a convenient veneer of fiction). 'Random' encounters, enforced time pressure, contrived consequences. cf "GM Force," if you can stand to read the Forge.
Feel free to use existing modules as examples
The modules, like the rules themselves, are only a starting point.
The only constraint I'm asking of you is that you can't dismiss or "solve" the issue by the flippant "just add time constraints to the adventure" thing.
Fine. Boost encounter difficulty. Throw in 'random' encounters when the party tries to rest too soon until they've met their quota. Force the plot along when they stall out, have the next encounter come to them, have it get harder the longer they wait to get to it, have the bad guys do something awful that they could have prevented if they hadn't been sitting around unnecessarily resting. Make any decision that's not good for the campaign, /bad/ for the PCs...
None of that is anything new to DMing with 5e. We all did that kinda thing back in the TSR era, we wished we could've gotten away with more of it in the WotC era, now we can. Go for it.
Enforcing attrition has always been somewhat hard in D&D. In many situations and scenarios, nothing prevents the party from going as slowly and carefully as possible, resting frequently to recover spells and hit points.
The innovations introduced in 4e and to a large extent carried over into 5e were designed with the purpose and intention of largely doing away with the attrition model that D&D had theoretically relied upon in the 1e, 2e, and 3e eras.
I don't think that's a fair characterization. Apart from the fact that we can't retroactively read their minds to divine the actual purpose, the innovations that 4e introduced that reduced the reliance on un-enforceable 'attrition' were structural and made class balance more robust, and were not retained by 5e. 5e is very nearly as unenforceable-attrition-model-dependent as the classic game (or 3e, for that matter).
5e retained overnight healing, but that's just a simplification of the rest-rememorize-heal-rest cycle that the classic game churned through to get everyone back up to full fighting strength. It kept something called a short rest, but it's an hour long, and not assumed after most encounters, so the impact is not at all the same.
And, really, even 4e didn't do away with the attrition model, it was just balanced whether you used attrition over a long day as a challenge, or not.
It is therefore rather ridiculous to not acknowledge that and act like nothing has changed, and that challenging the players through attrition - always a difficult proposition - is now somehow supported by the system. It's not.
But it is once again /required/ by the system to impose some semblance of class & encounter balance.