Since the context is the different places that a grizzled sailor has sailed to, I think we can be sure that the passage refers to New Spain in general, rather than Mexico City, which is landlocked.
EDIT: Here is the passage in question, from The Romance of the Pyrenees by Catherine Cuthbertson:
"Thomas, indignant at a punishment his heart told him that he deserved not, quitted England; and, as his native and much-loved Albion lessened to his view, he rashly made the most solemn and awful of vows never more to return. On his voyage to America the transport he was in was wrecked: many of the crew and convicts perished, while he with a few other individuals were saved from the fury of the storm by a Portuguese merchantman on its way from Mexico to Lisbon."
So lets start from the beginning, the origin of the word "Mexico" comes from the capital city of the Mexica's (popularly know as the Aztecs), one of the constitutent members of the Triple Alliance, composed of the Alcolhuas from Texcoco and the Tecpanecs from Tlacopan, and the Mexica (the people of Mexi) from Mexico-Tenochtitlan (Place of the Mexica-Land of Tenoch).
Upon the defeat of the Mexica, Cortez rebuilt the city into the image of a Spanish city and named it simply Mexico-City (redundant name since the "CO" particle denotes a city (altepetl) already in nahuatl).
Now, in time Mexico would become the cultural and commercial center of the Kingdom of New Spain, so for example in 1551, prince Philip gives out the necessary papers for the foundation of the "University of Mexico" which prints texts like "3 latin dialogues from Francisco Cervantes and Salazar" as far back as 1554, in which they talk about things like "Mexico (the city) and its surrounding territories", things like the "Royal Audience of Mexico" also start cropping up as Institutions in what was officially New Spain.
The term becomes common to describe the inhabitants as early as the 16th century, so for example Bernardino de Sahagun writes in the prologue of his 2nd volume of his "Historia General de la Nueva España" (translation from spanish by me):
"Certainly it would be very profitable to make a work so useful for those who wanting to learn this mexican tongue, like Ambrosio Calepino did for those wanting to learn the latin tongue and the meaning of its vocabularies... "
Fast forward to the 18th century and you have people like Francisco Javier Clavijero, Sor Juana Ines de la Cruz and Luis de Gongora y Argote writing about the "mexicanity" (mexicaneidad) of the territories, so for example, Clavijero writes in his "Historia Antigua de Mexico" (translation from spanish by me):
And so in the public government as in the domestic of the mexicans which we are going to now expose* in this book you can see the characteristics of political discernment for the sake of justice, love and public good...
Here we also see the early tradition of linking the old prehispanic empires to the new "mexicanity" that Clavijero and many other thinkers of the time are beginning to take as their own, see here when talking about the Mexicas and the Triple Alliance:
The nobility of Mexico and the entire Empire was divided in several classes which the spanish mistook under the name of "cacique". Each class had their rights and markings such that with even the humblest of dresses his position was known at first sight.
Particularly funny to me is the trip of Hasekura Tsunenaga to Spain in1614, as on his way he travels through Mexico, and so far as I can tell (though I dont have official sources on this, as my Japanese is still pretty basic), its at this time that the phonetic meaning of Mexico is coined for Japan as "Mexico", note there is a phonetic kanji for "Mexico" (メキシコ), but not for "New Spain" (ヌエバ エスパーニャ)
As even Japanese sources, and on this I apologize to the mods for using the japanese wikipedia, but the Japanese embassy in Mexico text's are in spanish which doesnt properly convey the context of him entering New Spain through Acapulco, to "Mexico City": 出航から3か月後の1614年1月28日、アカプルコ入港。3月4日、使節団の先遣隊がメキシコシティに入った
Had to do some source digging for this one, only got to it now. u/pizzapicante27 already covered some points which I'l expand on. Most question on New Spain here are on the 16th century, so I'm glad for a chance to talk about the 17th century which even in academia is less discussed – and my actual period of research.
As a short version: You're right that Mexico mostly meant the City of Mexico in colonial times; and adopted as the independent country's name only in 1821. But there are at least two other meanings for Mexico for larger regions that would fit your passage: one for the Gulf of Mexico (17th c.) and one for pre-colonial Mexico (18th c.). In addition the name “mexicanos” for the indigenous inhabitants of Mexico City was gradually taken up by creoles (descendants of Europeans and native people).
I'll go into these semantic changes now, and connect them to larger trends in the development of a “creole patriotism” in the end.
Although it's often difficult to distinguish between pre-colonial and colonial usage, most commonly Mexico was used by the Nahua for the Mexica capital city of Tenochtitlan. This use continued in colonial times for the colonial city of Mexico City, which was built on the former Tenochtitlan following its conquest through the Spanish.
So while Mexico then had a very local meaning, the term "mexicanos" was often used by the Mexica to refer to themselves, meaning the inhabitants of Tenochtitlan and Tlatelco. The Mexica by the late 15th century dominated the Triple Alliance in the Valley of Mexico, consisting of the Mexica, Acolhua and Tepaneca. This usage of Mexica was taken up in colonial times by the Spaniards to refer to the Mexica, or more generally to speakers of Nahuatl (then called "mexicanos").
There are many differing translations of "Mexico", from Nahuatl. One of the most accepted ones today is "the navel of the moon", from "Metzxico": metz(tli) (moon) and xic(tli)(navel, centre), used by Alfonso Caso in the late 19th c. amongst others. This meaning has been extended as a way for the Mexico to refer to their capital as the centre of their known world. Other interpretations connect the name to specific deities.
During the colony some creoles (Europeans born in the Americas) and Spaniards of colonial Mexico used the term for themselves - as a way to distinguish an upcoming "creole Mexican" identity from a European/Spanish one. The leaders of the the wars of independence were looking at different terms for the independent nation; only with the Plan de Iguala in 1821 was the name of Mexico officially adopted for the country, drawing on its centuries-long identification with the Mexica and the mexicanos, but also on a long tradition of creole scholars highlighting New Spain's pre-hispanic past.
.
The name for modern-day Mexico City changed quite a bit during the 16th century, depending on which group one looks at, with „Mexico“ just one of the options. Barbary Mundy has traced these complex changes: On the one hand, already Cortés had called it a „ciudad“ in his letters. This continues when it received the official city title by the Spanish Crown in 1548 (a special privilege) and it was called only „Ciudad de México“ by the Spanish city council (cabildo) from 1545 onwards.
On the other hand at least throughout the 16th century the name „Mexico Tenochtitlan“ continued to be used, both in official letters from Spain and in documents of the indigenous cabildo. Indigenous elites also used „Ciudad de Mexico Tenochtitlan“ in order to differ it from the sister city of Tlatelolco – some would continue to speak of Mexico Tenochtitlan into the 17th century. For you question this means that Mexico was used from the start for the colonial capital; but also that the name for even the city was adapted by different groups, with the pre-Hispanic „Tenochtitlan“ still in use for decades at least.
The next shift in meaning comes when Mexico starts to be applied not only to the city, but also to surrounding areas (roughly the Valley of Mexico) – at least in Spanish, probably less so in Nahuatl. This is important because this meaning would stick for centuries, and in some ways until today. Apparently it is still not clear when this usage became common (as James Lockhart and Susan Schroeder argue). But most scholars seem to agree that it was sometime in the 17th century. So while the indigenous scholar Chimalpahin writing in the early 17th c pretty clearly meant only the city with „Mexico“, creole scholars towards the middle of the century used it already in the larger sense. This shift has to do with an increasing creole influence and creole patriotism in New Spain.
Some short background on „creole patriotism“ will come in handy here. The term was popularized in academia by D.A. Brading and others and is often used in the context of Latin American independence wars – in colonial times creole elites had had access to high posts and privileges, but the highest posts like Viceroy and archbishop were mostly closed to them and open only to Spaniards. Grievances over these and economic shortcomings are described as a major reason why creole elites would eventually lead the push for independence. What's less well known is that a form of common identification of creoles with their American home regions (or patriotism) had started to develop much earlier on some parts of Spanish America. New Spain/Mexico is usually seen as special in that according to some scholars, creole patriotism had come up in Mexico City as early as the early 17th century.
One famous example of this is Bernardo de Balbuena, who in his aptly-titles Grandeza mexicana from 1604 would posit Mexico City as a major center, at least on par with European metropoles. This is a very different perspective from contemporary Spanish writers who would for a long time continue to describe the Americas as „backwaters“, whose climates and food would corrupt people who moved there. Balbuena writes
[México] is a city of notable order
Where the Spanish language is spoken
More purely and with greater elegance.
Apart from Balbuena's pride in Mexican Spanish here - note how Mexico still refers to the city only and not its surroundings. By this point already, Mexico City (“México”) had become for many creole elites a main example of the importance (and maybe even superiority) of New Spain. After all, this “heart of the world” lay between the important Asian trade – via the Spanish Philippines – , as well as the South American and Mexican silver – the life-blood of the Spanish empire –, which it connected to Europe – through Sevilla and later Cádiz. The central place of Mexico as economic and administrative centre is reflected in the reverence creole elites like Balbuena paid to it.
Some changes take place in creole views by the late 17th century, which we're jumping to now. At this time two best-known scholars in New Spain – and probably for all of Spanish America – were Carlos de Sigüenza y Góngora and Sor Juana Inés de la Cruz. For our topic Sigüenza y Góngora is more relevant, since he was actually strongly influenced by indigenous writings from his large archive. Unfortunately he did not finish his history writings on pre-Hispanic times, so I'll look at another short work of his regarding his use of “Mexico”, the “Alboroto y motín de los indios de México” from 1692.
The Alboroto is Sigüenza y Góngora's first-hand account of the Mexico City riots of 1691. These were carried out by parts of the city's population due the authority's mismanagement of a lack of food (and other reasons) – so the title's “México” clearly follows the traditional use, meaning the capital city. Overall in his account, mostly Mexico refers to the city and for Siguenza the larger territory is “New Spain” or the “Viceroyalty”, so far so good. More generally, Siguenza and Sor Juana are usually seen as creole scholars proudly upholding their patria of New Spain. Another work of his is titled “Paraiso Occidental" and focuses once more on Mexico City, as an earthly paradise – extending the ideas of Balbuena mentioned above.
Then again, I did find two passages that would fit better with your question. In these Siguenza discusses the “Seno Mexicano” in connection with corsar ships that were then often doing raids in the Gulf of Mexico.
This map by José Dias Portaly shows roughly the size of the Seno Mexicano corresponding the the Gulf of Mexico. Not that at the time this would have included Spanish possessions like what was then New Mexico, Tejas and parts of Florida. It also shows that at least in New Spain the term was still in use 100 years later in 1787, so quite close the your book's publication. Although I don't know enough about English literature to judge if it was in use in England at that time, it seems very probably since the term had been floating around for more than 100 years. So this seems like a good contestant for what you're looking for, especially given the maritime context of Siguenza's passages.
I'd also add here the Siguenza was an expert on New Spanish geography, who made state of the art maps of waterways, and of northern regions during an expedition there among other things. So that his use of terminology can be seen as quite representative for intellectuals there at the time. And also that even before Siguenza “Mexico” had started be used only for northern regions like those mentioned above, New Mexico and further north, that would definitely not be part of modern-day Mexico. A transposition of the meaning of “Gulf of Mexico” - for the Seno Mexicano - into English as “Mexico” seems like a good option for your question then.