Is it possible to use a shared library, compiled for example on a RedHat / CentOS system, on a Ubuntu system?
For the library's machine code to be executed the only requirement is for the architecture for which the library was compiled to be compatible with the Ubuntu machine's architecture.
Meaning that if the RedHat / CentOS library was compiled e.g. for x86-64 the Ubuntu machine's architecture must be x86-64 (or compatible) as well.
For the library to be functional, as Dani_I remarks in the comments, potential dependencies of the library must be satisfied.
Meaning that if the RedHat / CentOS library depends on other libraries, the Ubuntu machine's linker must be able to find the same libraries (or compatible ones) somewhere in the system; speaking of where those libraries are to be found, that depends strictly on the Ubuntu machine's linker's configuration.