I don’t think it would be easy, and it would be prone to not working very well (since web pages don’t actually have a simple thing that specifies their color palette). And it might be slow, since it would have to do a bunch of downloading to (try to) figure out the color palette.
But, in the hands of a capable and motivated developer, it might be do-able. (They’d just have to deal with, forever, the reports for all the sites where it doesn’t work well, and just keep tweaking it.)
Websites are able to define a colour in the head of a site. But there is only one colour for dark and light mode. Most websites have favicons, and maybe it’s possible to extract a colour from this image.
I think this is an interesting idea, and I have to try it out on my own theme, Ringo.