A viceroy is an appointed official who rules a country or province on behalf of a higher authority, typically a king or queen.
In Star Wars
Nute Gunray held the title of Viceroy in the Trade Federation. It is not clear whether the title has the same meaning in Star Wars as it does in reality. If the title is similar, the ruler who appointed Gunray has never been identified; we don't even know if it is a corporate title bestowed by the Trade Federation or a title bestowed by some Neimoidian planetary authority.
In the Foundation Series
Viceroys were rulers of provinces in the First Galactic Empire. On territories which split off the Empire, they often became independent kings. Inside the Empire, during the last centuries of its existence, they often revolted against the Emperor, sometimes successfully. During the Mule's reign, at least one person was known to call himself a Mule's Viceroy.