I have been using Firefox with Ublock Origin as my main browser for a long while. Usually when I get a privacy prompt, I reject cookies, or maybe some sites that are more difficult take me a to a panel that wants me to switch off loads of individual trackers.
How does Ublock handle the cookies? Obviously some are required for site functionality, such as being logged in here, but if I accept cookies (or can't reject them) then presumably they are still accepted? Or does it accept the essential ones and delete third-party trackers?
I don't think it does anything with cookies directly. It just blocks connections to domains and removes elements from pages that match patterns you give it. Removing the cookies/privacy banners does just that - removes the banner. This SHOULD opt you out of tracking as the laws generally require explicit permission, so not clicking the accept button should be enough. But if the sites follow those laws or not is a completely different matter.
Third party tracking cookies are normally blocked by their domain - when a tracking pixel is on the screen it reaches out to a known tracking domain which logs this visit and drops a cookie for that domain on the page. By blocking that domain the tracking request is never made and thus no cookie is dropped and so there is nothing to track you. Most tracking is done like this so it is quite effective. But it wont stop a first party cookie from being dropped or tracking done through that or any other data you send.
Note that the laws don't require permission for all cookies. Ones that are essential to the sites function (like a cookie that carries login info) are typically allowed and cannot be opted out of (you can always delete cookies locally though, the laws just cover what sites can use). And not all sites will respect these laws or try to skirt around them so none of this is 100% perfect by any means.
As far as laws go, I'm in the UK and AFIAK privacy laws are still the same as before we left the EU. Other countries such as the US seem to have less strict laws (apart from the CCPA) which means a lot of US news sites I visit will geoblock me as they don't want to comply with EU standards.
And other browsers can be configured to do the same. Though that is not ublock origin doing anything with the cookies and these settings can be enabled wtihout ublock (though you likely want ublock if you are enabling them).