The Dash to Panel Gnome Shell extension does exactly what you want and is highly configurable.
You can install it from Ubuntu software (search Dash to panel), or using the terminal with the command
sudo apt install gnome-shell-extension-dash-to-panel. Caveat: the extension is not automatically enabled. Log out and then back in. Then you will see the extension in Gnome Tweaks, and you can enable it there.
Alternatively, you can install the extension from Gnome extensions. This does not immediately work on a fresh Ubuntu install. See How do I install and manage GNOME Shell extensions? (answer by user364819) on how to enable installing Gnome Extensions from the website on Ubuntu.
To configure the extension, make sure you have "Gnome Tweaks" installed. In Gnome Tweaks, find the extension on the Extensions tab and click the cog icon to access the settings.