If you are in the same alliance and the captain has been offline for seven days, R3 or R4 members can spend 1,000 gold coins to replace them!
And you can do so by clicking the alliance icon on the bottom, then the members tab, then captain’s avatar, and choose “Replace Captain.”