By the looks of it, there’s a plugin to achieve exactly this, so save you rolling your own for it.
The plugin is: https://wordpress.org/plugins/permalinks-customizer/
I installed it to test that it does what you’re looking for. Here’s a screenshot that shows what you’d do: