You can enter Hong Kong from Shanghai with an American passport, but if you want to return to Shanghai from Hong Kong, it depends on the number of valid visas for China in the American passport. If you only have a valid Chinese visa of 1, you should apply for another Chinese visa at the Exit-Entry Administration Office of Shanghai Public Security Bureau before going to Hong Kong, otherwise you will not be able to enter the country when you return to Shanghai.
Extended data:
American passports are dark blue (see above for exceptions), and the American seal is printed in the center of the cover. The English word "PASSPORT" is engraved on the top of the national seal, and "United States of America" is engraved on the bottom. In particular, like other countries, the "e-passport" has a biometric mark printed on the bottom of the cover. The standard American passport includes 24 internal pages, and the 48-page passport for business and other frequent travelers is cancelled, but additional visa pages can be added.
Baidu Encyclopedia-American Passport
Baidu Encyclopedia-Passport Card