Depends. There are names that are "romanized" to Hungarian pronunciation rules, like Dosztojevszkij (Dostoevsky), or Kolumbusz Kristóf (Cristoforo Colombo - Hungarian puts the family name first), though it is no longer the practice, it's mostly used for historic names only. That is, Trump is written like that, and not as we would pronounce (something like "Trámp")
In general, if the source language has a latin alphabet, we try to stick to the original spelling in most cases, but it is not uncommon to replace non-Hungarian letters with the closest one. It's a bit more complicated in case of non-latin alphabets, especially Cyrillic due to a lot of shared history.
Unless it's a famous person who lived several centuries ago, probably would leave it as Yáñez, or if I (or more realistically, an average, not too technical user) were to not have an easy way to input the special characters, then as Yanez. Probably not as Yánez, even though we do have the letter 'á', but leaving it as is may be more misleading in terms of pronunciation then the non-accented version.