fixes #22638
Make GUI "Settings file could not be read. Do you want to reset settings to default values?" dialog actually clear all settings instead of partially keeping them when settings.json contains duplicate keys. This change has no effect on bitcoind because it treats a corrupt settings.json file as a hard error and doesn't attempt to modify it.
If we find a duplicate key and error, clear values before returning so that WriteSettings() will write an empty file, therefore clearing it.
This aligns with GUI behaviour added in 1ee6d0b.
The test added only checks that values is empty after a duplicate key is detected. This paves the way for the abort option in the GUI to properly clear settings.json, if the user selects the option, but the test does not currently check this entire mechanism (e.g. the file contents).