It's pretty simple, really. If it's possible to decline a foreign name in Russian, you do, and it's possible whenever the ending of the name allows it to fit into one of the three declension patterns for Russian nouns.
The names of males from English-speaking countries usually end in a consonant and are easily declined as masculine nouns. But foreign feminine names ending in a consonant cannot be declined.
This is true even if a man and a woman have the same name. For example, if a man is named Робин, the genitive is Робина:
У Робина Гуда был лук.
But if a woman is named Робин, her name cannot be declined.
Names, both male and female, that end in -а or -я are declined, whether they're Russian or foreign. But Russian given names never end in any other vowel, so foreign names ending in -о or -и cannot be declined. So for example, Антонио is not declined. This also means that -y diminutives such as Тони (Tony), Бэтси (Betsy), and Гарри (Harry) are also invariable.
Other Slavic languages have male names ending in -о, and these may be declined in their native languages, but not in Russian. Russian does have a declension pattern for nouns ending in -о, but it reserved for neuter nouns. So for example, Петро is not declined in Russian, even though the Russian form, Пётр is.
You should note however that Slavic language speakers do not necessarily view given names as immutable letter sequences the way Americans do. It is widely accepted that they change spelling and pronunciation depending on the language being spoken. For example, presidents Putin and Zelenskyy are both Vladimir in Russian Wikipedia and Volodymyr in Ukrainian Wikipedia. Thus when speaking Russian, we would usually refer to Петро using the declinable Пётр.
Using an indeclinable name in a sentence can be inconvenient and awkward for a native Russian speaker. For this reason, many women who are learning Russian use a declinable form with their friends. In most cases, this is simply a matter of adding -а. For example, Ann becomes Anna, Susan becomes Susanna, Mary becomes Maria. Men with indeclinable names such as Эндрю (Andrew) frequently adopt the recognized Russian form, in this case Андрей.
In the Russian Bible, declinable forms are used for almost all personal names — both male and female. The only exceptions I know of are the female names Раав (Rahab) and Мириам (Miriam). A few of the female names belong to the third declension, such as Руфь (Ruth) and Ноеминь (Naomi), but most end in -а or -я.
The modern trend is to preserve the native-language form when writing about a person in a formal context such as a book or news article, even when this form cannot be declined. But this isn't universal and doesn't necessarily apply to people who lived in the distant past. And so, for example, king James I of England is Яков I. And there are exceptions for a few persons living today, notably Queen Elizabeth II, who is invariably Елизавета II.
The same principle of what is declined applies to surnames:
У господина Смита была книга.
У госпожи Смит была книга.
Because the surname Смит ends in a consonant like a masculine noun, it is declined as a masculine noun when it refers to a man, but is an indeclinable feminine noun when it refers to a woman.
Generally speaking, surnames ending in -а or -я are declined. When they are declined, they are declined in the same way whether they refer to a man or a woman. But there are many exceptions. For example, if the surname ends in a vowel combination which is not used in Russian (such as -уа or -иа) or the final -а or -я is stressed such as Дюма́ or Зоя́. In these and other cases declining the foreign surname is seen as awkward and so is not done.
So the general rule is this: If the foreign given name or surname can be declined using one of the standard noun declensions, it is declined. But we refrain from using an exclusively male declension with a woman or a neuter declension with a man.