We consider the capillary folding of thin elastic sheets with pinned contact lines in three dimensions. The folding occurs due to the interaction between the elastic sheet and a droplet deposited on top of it. Firstly, we derive the equilibrium equations by minimizing the total energy of the system. This energy comprises the interfacial energies and the elastic energy, which is described by the nonlinear Koiter's model. Then we develop a time-splitting numerical scheme to solve the gradient flow dynamics. Following this dynamics, the system evolves towards the equilibrium state. At each time step, we first determine the droplet surface with a constant mean curvature by minimizing a squared area functional, subject to the boundary condition at the pinned contact line. The elastic sheet, discretized by the C1-conforming subdivision element method, is then evolved by taking into account the fluid pressure and the capillary force. We propose a novel remeshing strategy to avoid the need for interpolating the capillary force on the sheet boundary and to prevent simulations from breakdown due to distorted meshes. We perform numerical tests to demonstrate the accuracy of the numerical method, as well as its ability to predict folded structures for various types of sheets.