Normally of course a megohm is way higher than the recommended maximum for the 328P, hence the need to change something. One 'mechanical' way is to change out the stick pot. Or, you could correct in software. My own preference is easy and much less prone to noise pickup - use a buffer.
Here's an experiment with 1MΩ pot driving a 328P analogue input.
I made up a small stripboard buffer, using a single MCP6021 which is a common-or-garden rail-to-rail 5v op-amp and cheap as chips.
The result is it works perfectly, no different to a 5k pot, no noise pick-up or RF problems, it just works. I also did a small PCB layout (top of 3rd photo) to mount directly onto the pot tags. The buffer simply sits inline in the 3-wire pot cable, pos 5v, neg and wiper.
In the first & second photos the input from the pot is on the left, and output to the encoder on the right.
Conclusion - yes we can use 1MΩ stick pots without having to physically swap them out for lower values
