It is possible to measure 1MΩ, but I think that 10MΩ is too much.
The circuit impedance for a analog input should be 10kΩ or less for a reliable measurement.
You can go up to 100kΩ if you accept a little less accuracy and use a filter in software to reduce the noise.
The analog inputs do not really have a input resistance. They need a little charge when taking a sample to measure. You can provide that little charge with circuit impedance of 10kΩ or less or with a capacitor.
You can go up to 1MΩ when you add a capacitor between the analog input and GND. That way there is some reservoir and the Arduino doesn't even know that it is a reservoir instead of a circuit impedance of 10kΩ.
That capacitor can be for example 10nF (I think 1nF to 100nF is okay).
It is possible to select a range.
Suppose your sensor is connected to GND and A0. Then you can use a resistor of 100k from D2 to A0 and a resistor of 2M from D2 to A0. Keep D2 and D3 as INPUT. Then select one of the digitals pins, set it to OUTPUT and HIGH and measure A0 and after that set the digital pin to INPUT again. Now you can select the range.
You need a delay to let the 2MΩ fill the reservoir-capacitor.
I often use 1k and 100k for a extended range of a LDR.
Don't forget to take the average of many samples in the sketch. That will make the measurements a lot better.