For now as Ganesh described You need to use the JSON formatting based on conditions and updating the styles of the component. As online is tagged I am guessing we should talk only about this version.
Please be aware You can modify this styles of a column -> Use column formatting to customize SharePoint - styles
so for Your needs this kind of example:
"background-color": "=if(@currentField == 'A', '#2BBBAD', if(@currentField == 'B', '#4285F4', if(@currentField == 'C', '#aa66cc', if(@currentField == 'D', '#bbdefb', if(@currentField == 'E', '#cddc39', '' )))))"
will produce this kind of result
This is all already explained in Ganesh answer. What is worth mentioning is that in the near future there will be added a UI for this kind of column and list view formatting so keep an eye for updates :). This kind of feature was already introduced in this month PnP Community Call
Please check this:
I am looking forward for this to finally show in online :)