How to dependency plugin in another plugin?

In short yes, but things can get more complex than that when you are dealing with plugins that contain multiple modules.
One plugin can have many modules and its own chain of internal dependencies.

After you do that you have to include the dependency to B’s Build.cs file as well.