One of the more notable features of Android 7.1 is the ability for keyboards to directly insert GIFs into an application.
However, both the keyboard and target application have to be updated to handle the new functionality. Thankfully, Twitter has now done so with version 6.33.0-beta.556.
To use this feature, you will need a compatible keyboard (like Gboard), a device running Android 7.1 or later, and the latest Twitter beta release. Once you have all that, inserting GIFs should come up as an option on the keyboard.
Just like the existing GIF button in the Twitter app, this works with both tweets and DMs. I expect this will arrive in the non-beta Twitter app with the next update.