Several observables sensitive to the fragmentation of b quarks into b hadrons are measured using 36 fb-1 of s=13 TeV proton-proton collision data collected with the ATLAS detector at the LHC. Jets containing b hadrons are obtained from a sample of dileptonic tt¯ events, and the associated set of charged-particle tracks is separated into those from the primary pp interaction vertex and those from the displaced b-decay secondary vertex. This division is used to construct observables that characterize the longitudinal and transverse momentum distributions of the b hadron within the jet. The measurements have been corrected for detector effects and provide a test of heavy-quark-fragmentation modeling at the LHC in a system where the top-quark decay products are color connected to the proton beam remnants. The unfolded distributions are compared with the predictions of several modern Monte Carlo parton-shower generators and generator tunes, and a wide range of agreement with the data is observed, with p values varying from 5×10-4 to 0.98. These measurements complement similar measurements from e+e- collider experiments in which the b quarks originate from a color singlet Z/γ∗.