depends on how the batteries are setup. if operating voltage matches and you get an adapter you can definitely use them together.
example
https://www.amazon.com/Dewalt-Ryobi-battery-adapter/s?k=Dewalt+to+Ryobi+battery+adapter
https://www.amazon.com/battery-adapter-greenworks-strikemaster-connector/dp/B08PC6GH4H