Uploading.

Is it possible to upload a sketch from a chip to an empty sketch. ie. a chip from an unknown project, to find out its code.

This has been discussed many times before.
You can search for yourself.

Any code would be machine code which might be converted to assembler.
But, you 'will not' get C++ source code.

there is always a way to do something.

Are you trying to extract the code or just identify the device.?

To read the code, simply remove the memory ic and read in any reader,
a 24/25 range reader is only like 3 or 4 bucks.

then pass the binary thru a decompiler

if(notexist){writeone();}.

Presto you have Sudo code that may even recompile with edits depending on your selection of tools.

If you are simply trying to duplicate a current device then just copy the data from the memory ic to another, unless the code also contains other checking to detect this abuse like Mac address checking or other undisclosed methods.