First-order coil-to-flower transition of a polymer chain pinned near a stepwise external potential: Numerical, analytical, and scaling analysis