How to set a partition type to ef02 with fdisk?

user2313067 is absolutely correct. What gdisk refers to as EF02 is shorthand for a GUID of 21686148-6449-6E6F-744E-656564454649 -- that is, it identifies a BIOS Boot Partition. There is no equivalent partition type code for MBR.

To elaborate further, the GRUB bootloader, when installed in BIOS mode on an MBR disk, stores part of itself in the MBR, part of itself in the sectors between the MBR and the first partition, and part of itself in files on a partition that you specify (normally in the /boot/grub or /boot/grub2 directory in Linux). The post-MBR sectors are officially unallocated, so GRUB storing part of itself there is potentially a bit risky, but it usually works fine. Under GPT, the sectors immediately following the MBR are used by the GPT data structures themselves; and prior to the release of Advanced Format disks, it was common for the first partition to begin on the sector immediately following those data structures. In other words, there is no equivalent under GPT to the (almost) safe post-MBR space. Thus, to enable BIOS-mode booting on GPT disks, GRUB's developers created the idea of a BIOS Boot Partition, where boot loader code could be stored "raw." In principle, the idea could be applied on MBR disks, too, but AFAIK nobody's done that -- at least not for GRUB. (OS/2's boot loader did have its own partition type code [0x0A], and there may be other boot loaders that do something similar.)

The bottom line is that you probably don't need to create a special partition for your purposes. That said, your question doesn't specify what you're trying to accomplish, in the end. (Creating a BIOS Boot Partition is not a goal in and of itself; presumably you want to do something like install a new OS or a new boot loader for an existing multi-boot configuration.) Depending on what your ultimate goal is, you might need to do something special.