Yes. There are examples of keys on page 160 of the Player's Handbook (PHB) in the trinkets list, such as "An Old Key". However, whether the key will serve the intended purpose of opening a lock comes down to your DM. Arguably, to be able to fabricate a key that will function to open the lock, the caster will need a detailed, accurate image of the key to know what to create. Without this, while the caster could create a key, it would be a perfectly sound ruling that it would not simply open any lock.