In the coming sixth-generation era, unmanned aerial vehicles (UAVs) have been explored for convenient air access and strong environmental adaptability to provide communication services for ground Internet-of-Things (IoT) devices. However, the inherent broadcast nature of wireless makes UAV communications vulnerable to eavesdropping attacks. This paper explores a secure uplink communication in a heterogeneous network, where a UAV provides communication services to ground IoT nodes in the presence of an eavesdropper. We propose a transmission scheme to maximize the overall sum secrecy rate, in which the cooperative jamming technique and coalition formation game are employed, and the UAV endurance is considered. Specifically, a double-layer optimization problem is formulated, including a non-convex optimization problem in the lower layer, and a game theory problem in the upper layer. We use block coordinate descent and successive convex approximation methods to decompose the lower layer problem into UAV deployment and power allocation sub-problems, and convert them into a difference of two convex functions programming problem and a second-order cone programming problem, respectively. Moreover, we develop an algorithm to solve the upper layer problem, obtaining a stable coalition formation. Simulation results show that the proposed transmission scheme can effectively improve the overall sum secrecy rate, and has dynamic adaptability to eavesdropping attacks.