You can access the property via the light's shadow_enabled
property. So, this...
$DirectionalLight.shadow_enabled = true # (or false)
To your second question of how to access it from a button in your settings menu... That really depends on how you've put your game together, but the most likely answer is via a signal
.