Could Japan build a 20-inch-gunned Yamato if rival navies already had 18-inch battleships?
Short answerIt might try much harder, because an existing 18-inch foreign battle line removes the overmatch that made the more reliable 18.1-inch gun sufficient.
NotesJapan historically explored a weapon around this scale but could manufacture the 18.1-inch gun more reliably. In the real strategic setting, that smaller weapon already offered substantial overmatch, so accepting the easier design was rational. If British and American ships had entered service with 18-inch guns, Japan would lose that margin. The altered competition could justify the expense and low production yield of forcing a 20-inch weapon into service for a larger Yamato-type battleship.