This is a simple modification of @clarkwinkelmann's Color Circles for Groups extension. Usernames on posts will now have the same colour as the user's top rank.
Note that this only changes the colour on posts for now. This may be updated in the future to set colour in all places.
Use composer to install this extension on your forum:
composer require mickmelon/flarum-ext-coloured-usernames