You can import other dlls or source code into Unity, as long they don’t have dependencies on anything that can’t be referenced or used by license limitations.
As for the other way around, using Unity code to be used in another engine that’s a different story. You can’t use much of the classes exposed in UnityEngine.dll without the engine (application etc) actually running. So you can’t use any code that depends on Unity. However, you might want to port the code into your other engine should you want to, replacing Unity types with the equivalent target types.