To fix this "zombie" process, the most effective method is to force the upload to fail by force-quitting the Messages app and turning on Airplane Mode; when you reopen the app, the lack of internet will eventually cause the spinning circle to time out and turn into a red "Not Delivered" error, allowing you to finally delete the message. If the app remains frozen, you can bypass the chat interface entirely by going to Settings > General > iPhone Storage > Messages > Photos and deleting the stuck images directly from the list.
It is also helpful to perform a Force Restart—press Volume Up, Volume Down, then hold the Side Button until the Apple logo appears—to clear the system cache. To prevent this in the future, tap Options at the top of the sharing screen and select "Individual Items" to send the actual files rather than generating an iCloud link.