Cocoa plants are found on the logs of the small jungle trees, though only on naturally generated trees. Player grown trees will never generate cocoa plants. Cocoa plants will drop cocoa beans when they’re destroyed, which can then be replanted on jungle logs.
Cocoa plants grow in 3 stages, the first stage is small and green, the second stage is larger and yellow-ish, the last stage is even large and has a brown and orange color. It’s possible to use bonemeal to instantly grow the cocoa plant, though they grow relatively fast, so it’s not really needed. Cocoa plants in the first 2 stages only drop 1 bunch of cocoa beans, the last stage will drop 3.
Cocoa plants are very easy to farm as they can simply be placed on a wall of logs, right next to each other. They can be placed on each side, so you could plant the cocoa beans on both sides of the jungle log wall. Water and pistons will break the cocoa plants, which will drop the cocoa beans. This means it’s very easy to create a semi automatic harvesting and collection system.