Yes, it is possible if the rules of the respective national athletics federations allow it. National records are governed by national athletics federations and, while everywhere the big line is that you need to be a citizen of the country to break a national record, there is no uniform way to define the national record of a country. The devil is in the details, as usually.
Let's consider the case of Duplantis, assuming that ratification happens smoothly (sending proof of doping control to the national federation and such)
Swedish record
Not much doubt. He is a Swedish citizen, competing for Sweden at the European championships. The Swedish federation has a list of improved national records on their website. His performances in Berlin are listed.
American record
this is the more contentious one as he was competing for Sweden instead of the USA. The rules of USATF are very clear:
RULE 261 NATIONAL RECORDS
- There shall be six (6) categories of national records as follows:
(a) An American Record, which shall be the best performance made by an American citizen or relay team composed entirely of U.S. citizens in an athletics event held within the United States or abroad.
Is Duplantis a US citizen? Yes. This means he can break American records. While his record is as of today not listed on the website of USATF (because they only update the list at the end of the year) his performances of 2017 are listed as American Junior Record, for which the rules are
An American Junior Record, which shall be the best performance made by an American citizen or relay team composed entirely of U.S. citizens who are Juniors. (See Classifications in Rule 141.)
Very hard to argue that he would be eligible for American Junior records, but not for American records.
While the US rules are very broad, many other federations have further rules. Often you need to be member of a club affiliated to the federation or eligible to compete for the country or something to that end. USATF can in the future restrict their rules, making Duplantis ineligible for American records, if they would feel inclined to do so. But under today's rules it is an American record.