Can I use code from a supplementary material and publish it as part of my own paper?
If the published code is licensed, follow the terms of the license. This website sums up in a concise way what the most common open source licenses allow you to do or not.

If you cannot find a license, or if you are sure there is none, then by default you have almost no right to do anything with it (in most countries, no license means all rights reserved to the author). You still have the right to contact the corresponding author of the article, or the author of the code (if they are not the same person, and if you can find the contact info of the author of the code), and request permission to reuse their code, or even better ask them to explicitly attach the license of their choice to their code. Then, follow the license terms.