So I think you would be able to use string subst feature of the variables …following on what @rvietor suggests…
I don’t do it for export but here I shared how I export my jpg edits in a way that automatically names them to match the raw files but it creates a parallel set of folders one with the raw files and xmp and one with only the edited exports…makes it easy to scroll through and view them… and it keeps the same file structure in both…
Basically you specify the variable, then a “/” search pattern, “/” what to replace that with…
You might be able to work that out to give you what you need on import…
https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/#string-substitution
Edit it might even be simpler…
If your files are all DSC_(framenumber)
then this one might work…

Just remove the DSC_