With PIM Sparse Dense mode, and interface configured for this type of PIM operation will uses sparse mode if an RP is known for the group. If no RP is known, it will operate in dense mode. The configuration is simple.

R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip pim sparse-dense mode
R1(config-if)# exit

It is typically good practice that if using sparse-dense mode, you should put all physical interfaces into sparse-dense mode.