Yes, you can. Under an Open Source license, any kind of modification or enhancement you bring to the editors' code must be released under the same Open Source terms. Also, you may not alter or remove the copyright notices or the LICENSE.md file. If you include CKEditor 4 or CKEditor 5 in an application with its own copyright, the terms must clearly identify which parts of the code are not bound by your copyright.
For a commercial license, no legal requirements to make the source code of your software and your modifications or custom plugins public apply. A license protects your intellectual property, so if you create new code for CKEditor 4 or CKEditor 5, it will belong to you. You will not need to share it with others, and you will have legal claim if someone appropriates it.