I think there are issues with AMD + OpenCL in flatpak: Darktable Flatpak doesn't recognise OpenCL even with -d opencl flag · Issue #68 · flathub/org.darktable.Darktable · GitHub
Basically it cannot be achieved at the moment, you can try the non flatpak version.
With Nvidia it could work as the driver is included in the flatpak sandbox. I haven’t tested this personally.